From patchwork Fri Jan 26 11:14:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 125949 Delivered-To: patch@linaro.org Received: by 10.46.84.92 with SMTP id y28csp255583ljd; Fri, 26 Jan 2018 03:15:04 -0800 (PST) X-Google-Smtp-Source: AH8x226AfnYa2zWA0NH+3BhXlSl3eJI5LfsleBfcpN90VDg0KOqsW2jH/A0hwmiwUcK22a2W1Roo X-Received: by 2002:a17:902:d681:: with SMTP id v1-v6mr13869872ply.170.1516965304666; Fri, 26 Jan 2018 03:15:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516965304; cv=none; d=google.com; s=arc-20160816; b=aqtEOV/wSCzJzd3KsmnSzomYCwTaDMQhCKEESJ6Pguy3xQPXdqaTK86EHvusWjbkYU L48MyLuuQLvk+x1f6gA2pXjuIly0ru39/SXQfP/befX669x4YngpK9xAPGlaGLE8atHK udiL/1zjMuQINISEvCuKSrev8y+FGKe7F6VICD/wrkJc1qs5UEABvqVuq2RvkvWqxRrz LwXEcvFsBoryLEMVXooBnAhQTwteAYMqCu84T488/MSlvEz3ChxGAPuubHPkD1YHqJzx CGymWGVWAf0k+qBArP+cUEGjd8PpkCcBi/YL/Dbvx5RT/YfJQB0gYqeuMrWwUfs9b+Kl FeXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:cms-type:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter :arc-authentication-results; bh=V+mqsoMZaeFy5heNDBf7MzU3XVqqHFKdSy3sNLE0tS8=; b=fipcidzw+DYSMWWKP0BFkNHUjyIa/Jj4pEaF6mgaLY6k9f8OePh04Rf5GwZTMUibVO o9drZqJJx9lyGM7rJS9Vo+A04vHQrq/O6tmvZ4fVAZthdg5J6KULuAVGECUnAs7uR+j5 YAVmcDPFIEWQwXekVJY2OiZIWkJCakLaJP6TEpVcyxvIbiYr0VQzg6NReQ0AZmtDHKKJ meyYiQmEjO9XNwFITTxSmrkAsMf8vp1+0fco1sNLc9aOBHklYHZ5DO7rE4yzJJ9EVJPO kO3baOuBxTR++UIo8jEfD0ILVrU+xiOX1ig0X3IeF94fgvf0xIMAM2gd0IKsMvu3Et12 EN6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=LrgsyCzK; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g11si2870899pgf.367.2018.01.26.03.15.04; Fri, 26 Jan 2018 03:15:04 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=LrgsyCzK; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751511AbeAZLPB (ORCPT + 28 others); Fri, 26 Jan 2018 06:15:01 -0500 Received: from mailout2.w1.samsung.com ([210.118.77.12]:60764 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750819AbeAZLO6 (ORCPT ); Fri, 26 Jan 2018 06:14:58 -0500 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20180126111455euoutp02f075ace022ce4b91f268a15d1fab6fb6~NV_YoWf7E3207632076euoutp02F; Fri, 26 Jan 2018 11:14:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20180126111455euoutp02f075ace022ce4b91f268a15d1fab6fb6~NV_YoWf7E3207632076euoutp02F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1516965295; bh=V+mqsoMZaeFy5heNDBf7MzU3XVqqHFKdSy3sNLE0tS8=; h=From:To:Cc:Subject:Date:References:From; b=LrgsyCzKfpgbhGAUU9LMXr6UnWLMASxKDmzbG/SLnq0E3VFJGVE8Gn4XlCoeqFF2F 5I9yo+eefsKZhd6U55szLARsc7BpTZsmejGHxxHQ5Sq7AIa8sf5MfZnK09coTlmecD 8SQvuUCV3Mfh50FCao5sJqTx5QQw4q4McZA7D9a4= Received: from eusmges3.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20180126111454eucas1p25dcd4e353f2d1397447a1cc27b819914~NV_X2GN461403914039eucas1p2v; Fri, 26 Jan 2018 11:14:54 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges3.samsung.com (EUCPMTA) with SMTP id 2C.72.12867.EAD0B6A5; Fri, 26 Jan 2018 11:14:54 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20180126111453eucas1p1330d8561386c3cf2bb457bc22c0d99a8~NV_WvawRL3060830608eucas1p1u; Fri, 26 Jan 2018 11:14:53 +0000 (GMT) X-AuditID: cbfec7f2-f793b6d000003243-f0-5a6b0daeec7e Received: from eusync3.samsung.com ( [203.254.199.213]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id D1.91.18832.DAD0B6A5; Fri, 26 Jan 2018 11:14:53 +0000 (GMT) Received: from AMDC2765.digital.local ([106.116.147.25]) by eusync3.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0P35009HGTWNTP90@eusync3.samsung.com>; Fri, 26 Jan 2018 11:14:53 +0000 (GMT) From: Marek Szyprowski To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Marek Szyprowski , Russell King , Catalin Marinas , Will Deacon , Bartlomiej Zolnierkiewicz , Inki Dae Subject: [RFC 1/2] arm: cacheflush syscall: process only pages that are in the memory Date: Fri, 26 Jan 2018 12:14:40 +0100 Message-id: <20180126111441.29353-1-m.szyprowski@samsung.com> X-Mailer: git-send-email 2.15.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrEIsWRmVeSWpSXmKPExsWy7djPc7rreLOjDFb+FrHYOGM9q8X7ZT2M FpPuT2Cx2PT4GqvF5V1z2CzWHrnLbrH5w0s2i5cfT7A4cHismbeG0aOluYfNY/OSeo++LasY PT5vkgtgjeKySUnNySxLLdK3S+DKaL9+h7HgD2/F3aVBDYyd3F2MnBwSAiYSW0+cYIWwxSQu 3FvP1sXIxSEksJRR4u/ZX1DOZ0aJaZu+McJ0HDzbAZVYxijxcuV/FpCEkEADk8SVLVIgNpuA oUTX2y42EFtEwE3iRmMHE4jNLNDGJLF9R0kXIweHsEC4xJdH9SBhFgFVibN3j4PN5xWwlWi8 s5QNYpe8xOLvO8F2SQj8ZJVomjONBSLhIjGvfTcThC0s8er4FnYIW0ais+MgVLyfUaKpVRvC nsEoce4tL4RtLXH4+EVWiHv4JCZtm84Mco+EAK9ER5sQRImHxKfne6Ch4iix4tYRRogXYyWa /uxmmsAotYCRYRWjSGppcW56arGxXnFibnFpXrpecn7uJkZgTJ7+d/zTDsavJ6wOMQpwMCrx 8Brcy4wSYk0sK67MPcQowcGsJMJrxpkdJcSbklhZlVqUH19UmpNafIhRmoNFSZzXNqotUkgg PbEkNTs1tSC1CCbLxMEp1cCo9PSUSewJIdekoJ9zM2efZO4tmzv3UGD5TzmuRz6pTMvlhJUW 6XLct998lPv7QVE10WUSqSuyvh/foqxnWHa3TdRglrj5UvtVnH/6n37bts6sPThBaN6W/Tcf /boS/efBr/q3lXXKf2qtp1fx/DVbKFaQH/8+UP2RodI345LHcwyeLFNq+HxViaU4I9FQi7mo OBEAH/xTfMUCAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrHJMWRmVeSWpSXmKPExsVy+t/xq7prebOjDCY+krHYOGM9q8X7ZT2M FpPuT2Cx2PT4GqvF5V1z2CzWHrnLbrH5w0s2i5cfT7A4cHismbeG0aOluYfNY/OSeo++LasY PT5vkgtgjeKySUnNySxLLdK3S+DKaL9+h7HgD2/F3aVBDYyd3F2MnBwSAiYSB892sEHYYhIX 7q0Hsrk4hASWMErsffaLGSQhJNDEJPH1mhCIzSZgKNH1tgusQUTATeJGYwcTSAOzQAeTxLK/ y9hBEsIC4RL/5j4Ba2YRUJU4e/c4I4jNK2Ar0XhnKdQ2eYnF33eyTWDkXsDIsIpRJLW0ODc9 t9hQrzgxt7g0L10vOT93EyMwVLYd+7l5B+OljcGHGAU4GJV4eA3uZUYJsSaWFVfmHmKU4GBW EuE148yOEuJNSaysSi3Kjy8qzUktPsQozcGiJM7bu2d1pJBAemJJanZqakFqEUyWiYNTqoHR V026MUvLLlnl44QTixfNac3equ6qtHp9m85N5+lnXhmvrK2IkL4ROb978Y2vl/Vb67Yu2fXZ YPuS23W6h3NqWz/erd7PIHRl5rQ3TUs3e5Q9b7Li8ajlemM2R9K+TKazk+VF5Kfa4xulryv/ 2eEVXXz/wpazDDwiptxPAoszLvWsdlzyY7WrEktxRqKhFnNRcSIAnPm6SBECAAA= X-CMS-MailID: 20180126111453eucas1p1330d8561386c3cf2bb457bc22c0d99a8 X-Msg-Generator: CA CMS-TYPE: 201P X-CMS-RootMailID: 20180126111453eucas1p1330d8561386c3cf2bb457bc22c0d99a8 X-RootMTR: 20180126111453eucas1p1330d8561386c3cf2bb457bc22c0d99a8 References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org glibc in calls cacheflush syscall on the whole textrels section of the relocated binaries. However, relocation usually doesn't touch all pages of that section, so not all of them are read to memory when calling this syscall. However flush_cache_user_range() function will unconditionally touch all pages from the provided range, resulting additional overhead related to reading all clean pages. Optimize this by calling flush_cache_user_range() only on the pages that are already in the memory. Signed-off-by: Marek Szyprowski --- arch/arm/kernel/traps.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) -- 2.15.0 diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c index 5e3633c24e63..a5ec262ab30e 100644 --- a/arch/arm/kernel/traps.c +++ b/arch/arm/kernel/traps.c @@ -564,23 +564,36 @@ static int bad_syscall(int n, struct pt_regs *regs) static inline int __do_cache_op(unsigned long start, unsigned long end) { - int ret; + struct vm_area_struct *vma = NULL; + int ret = 0; + down_read(¤t->mm->mmap_sem); do { unsigned long chunk = min(PAGE_SIZE, end - start); + if (!vma || vma->vm_end <= start) { + vma = find_vma(current->mm, start); + if (!vma) { + ret = -EFAULT; + goto done; + } + } + if (fatal_signal_pending(current)) return 0; - ret = flush_cache_user_range(start, start + chunk); - if (ret) - return ret; + if (follow_page(vma, start, 0)) { + ret = flush_cache_user_range(start, start + chunk); + if (ret) + goto done; + } cond_resched(); start += chunk; } while (start < end); - - return 0; +done: + up_read(¤t->mm->mmap_sem); + return ret; } static inline int From patchwork Fri Jan 26 11:14:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 125948 Delivered-To: patch@linaro.org Received: by 10.46.84.92 with SMTP id y28csp255566ljd; Fri, 26 Jan 2018 03:15:03 -0800 (PST) X-Google-Smtp-Source: AH8x227YaM1Cz7yc/9YNL5UcVoYQDEPlZumdLNx5wkSHy71SkeGxDLSo73U+RfzEe1fxej83dWi6 X-Received: by 2002:a17:902:ab8d:: with SMTP id f13-v6mr14425547plr.215.1516965302945; Fri, 26 Jan 2018 03:15:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516965302; cv=none; d=google.com; s=arc-20160816; b=K4C1EAklnsf53iq4OELcgCKZL59M/CZoyf9qiM3iGuARGqJjQvMIwjgxgzujPlDyx5 rSfgAdh8MhB8tyDRzbfjRMDh0o35zr86cxnBXyZBgxlaLlhkYku2ecTvuqPVlQ2bBpYr LaQV79r5KOsONEba6aiF5hcVsViQaPoqlsRSlcSg24UFyW9RQX7GxnLTdhpE97RQO6Sg FjKzHYdLoDTjIiv1DW3tqYqkAorZI5NyFQNPv3vcxZni1gLSA0HcrDVJDTrf95IYoB0F wn2tVIsSSNAua9n5crHSdFNhFTr/wqADtBoytGHsS1bDzMs/uxZDvP7dzRIgL4zU95at 66/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:cms-type:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature:dkim-filter :arc-authentication-results; bh=82jgTYJf7JOtRb1dLL5WCL5R+GltnSzxi7PhfxL834E=; b=AHuvmmRmsKbRrbJwfKpn7Xm/VbqOwfRtrYfMc30G6pOC9zrUqBgvY6ROqIuEo/l1rs wX40rseYQVIF9CXrJuiflOd7ZapwKFcWOu9/En9RgLMkK8McfYdA13Dk5fKLZjMCnAG3 ie1vYVTLe0MdEMaiGQ6H+MSKMBdqM75vcYoimKH7gAeSpqJ/8dm4gCY+Tsbxxp+pMCRh qcAS5cfzv9JjDUjokaOkCPF5zlnnmzptEyt3TogSiGA4JrQkEkx/7lj1x+slfhYknGc0 qvxs2vU5qOYsecRZ1F+3S2yDOHOvlthnA+cVHo0xgcj+I5OJkamPJfB74gkVaoSUPTW2 WRqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=mo+hpxsS; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g11si2870899pgf.367.2018.01.26.03.15.02; Fri, 26 Jan 2018 03:15:02 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=mo+hpxsS; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751427AbeAZLPA (ORCPT + 28 others); Fri, 26 Jan 2018 06:15:00 -0500 Received: from mailout1.w1.samsung.com ([210.118.77.11]:54039 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750730AbeAZLO6 (ORCPT ); Fri, 26 Jan 2018 06:14:58 -0500 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20180126111455euoutp0183e2a6b870573f683d9094b34bd1dde5~NV_Yxeymn1357213572euoutp01K; Fri, 26 Jan 2018 11:14:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20180126111455euoutp0183e2a6b870573f683d9094b34bd1dde5~NV_Yxeymn1357213572euoutp01K DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1516965295; bh=82jgTYJf7JOtRb1dLL5WCL5R+GltnSzxi7PhfxL834E=; h=From:To:Cc:Subject:Date:In-reply-to:References:From; b=mo+hpxsSHWXbsBT0OdGh+RPux3AicpyroRgtPMpYt+EoOkD9/ru8rk5GF+i1CwjJl rJ9BY0gITVonOVsHTTIOGs8Vqp5cOHdev1CHdLv86SB5GSgGC5wBqaN/tXSDjk3TLO 1rIFOX9V16IH6Mquc21KrYb3qPvB+MbHGu7lvpk4= Received: from eusmges2.samsung.com (unknown [203.254.199.241]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20180126111454eucas1p2d2ed13f872a8169f0f870273e26f50cf~NV_YA14JE2192121921eucas1p2e; Fri, 26 Jan 2018 11:14:54 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2.samsung.com (EUCPMTA) with SMTP id 6F.D6.12907.EAD0B6A5; Fri, 26 Jan 2018 11:14:54 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20180126111453eucas1p178663ac7b17d0c92cc889a42b3f5bcec~NV_XHRbDm3062030620eucas1p1z; Fri, 26 Jan 2018 11:14:53 +0000 (GMT) X-AuditID: cbfec7f1-f793a6d00000326b-ea-5a6b0daed101 Received: from eusync3.samsung.com ( [203.254.199.213]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id B1.90.20118.DAD0B6A5; Fri, 26 Jan 2018 11:14:53 +0000 (GMT) Received: from AMDC2765.digital.local ([106.116.147.25]) by eusync3.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0P35009HGTWNTP90@eusync3.samsung.com>; Fri, 26 Jan 2018 11:14:53 +0000 (GMT) From: Marek Szyprowski To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Marek Szyprowski , Russell King , Catalin Marinas , Will Deacon , Bartlomiej Zolnierkiewicz , Inki Dae Subject: [RFC 2/2] arm64: compat: cacheflush syscall: process only pages that are in the memory Date: Fri, 26 Jan 2018 12:14:41 +0100 Message-id: <20180126111441.29353-2-m.szyprowski@samsung.com> X-Mailer: git-send-email 2.15.0 In-reply-to: <20180126111441.29353-1-m.szyprowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrPIsWRmVeSWpSXmKPExsWy7djPc7rreLOjDD5+krfYOGM9q8X7ZT2M FpPuT2Cx2PT4GqvF5V1z2CzWHrnLbrH5w0s2i5cfT7A4cHismbeG0aOluYfNY/OSeo++LasY PT5vkgtgjeKySUnNySxLLdK3S+DKODHlM0vBOf6KA+/EGxj38HQxcnJICJhI3PrfwgJhi0lc uLeerYuRi0NIYCmjxPyHp6Ccz4wSbbd3ssN03N22nREisYxRYtHFTiaQhJBAA5PElS1SIDab gKFE19suNhBbRMBN4kZjB1gNs0Abk8T2HSUgtrBAosSTjqmsIDaLgKrEpN51YAt4BWwlNv/c yASxTF5i8fedYHM4Bewkbl54wQ6yWEJgApvE74ktQA4HkOMisfupJ0S9sMSr41ugDpWRuDy5 G+q1fkaJplZtCHsGo8S5t7wQtrXE4eMXWSFu45OYtG06M8RIXomONiGIEg+J/onHocY4Sky8 cgwaKBMZJRY8bGGdwCi9gJFhFaNIamlxbnpqsZFecWJucWleul5yfu4mRmC0nv53/OMOxvcn rA4xCnAwKvHw3ridGSXEmlhWXJl7iFGCg1lJhNeMMztKiDclsbIqtSg/vqg0J7X4EKM0B4uS OK9tVFukkEB6YklqdmpqQWoRTJaJg1OqgdGu2/tuep0k6+KmQ89dJRiLpm2oXzN5emQz942v h/9f9TfU5LztaVNpJqST7mZyJvuI8tpMxzet7vbzTm3/wKxevSu0Sco38f8bw3OiDRq13/8p +G685qUfrfb54LkDR9VcDh+Zc9eF2fNGmEvrGfdDTn9aDwp+X3pvT4vG5pgQk4mGTFG7JJRY ijMSDbWYi4oTAd+1CITSAgAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprKLMWRmVeSWpSXmKPExsVy+t/xq7prebOjDNqnm1psnLGe1eL9sh5G i0n3J7BYbHp8jdXi8q45bBZrj9xlt9j84SWbxcuPJ1gcODzWzFvD6NHS3MPmsXlJvUffllWM Hp83yQWwRnHZpKTmZJalFunbJXBlnJjymaXgHH/FgXfiDYx7eLoYOTkkBEwk7m7bzghhi0lc uLeeDcQWEljCKNF4swzCbmKS+HpNCMRmEzCU6HrbBVYjIuAmcaOxg6mLkYuDWaCDSWLZ32Xs IAlhgUSJ203TwIpYBFQlJvWuA4vzCthKbP65kQlimbzE4u87wWo4Bewkbl54wQ6xzFaiY/ER xgmMvAsYGVYxiqSWFuem5xYb6RUn5haX5qXrJefnbmIEBta2Yz+37GDsehd8iFGAg1GJh/fG 7cwoIdbEsuLK3EOMEhzMSiK8ZpzZUUK8KYmVValF+fFFpTmpxYcYpTlYlMR5e/esjhQSSE8s Sc1OTS1ILYLJMnFwSjUwhjpwGF2ylfdJz+1jrWM6XD/R/NlF1dkZExZVy0zjLbK7WvXSbkaf +OWDJZzWP7W/BPjE3TkQIqfxPnSJDsPHKZtn6pqkn+hzjjlS6bh57wuWe9PfrGu03ti+si6f 7eGe+xFBDUY/GxO0l9x5XJ+4rV9VRLjmlp32ts7tJt81Oa3TvSbqdj9VYinOSDTUYi4qTgQA oUMsdygCAAA= X-CMS-MailID: 20180126111453eucas1p178663ac7b17d0c92cc889a42b3f5bcec X-Msg-Generator: CA CMS-TYPE: 201P X-CMS-RootMailID: 20180126111453eucas1p178663ac7b17d0c92cc889a42b3f5bcec X-RootMTR: 20180126111453eucas1p178663ac7b17d0c92cc889a42b3f5bcec References: <20180126111441.29353-1-m.szyprowski@samsung.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org glibc in ARM 32bit mode calls cacheflush syscall on the whole textrels section of the relocated binaries. However, relocation usually doesn't touch all pages of that section, so not all of them are read to memory when calling this syscall. However flush_cache_user_range() function will unconditionally touch all pages from the provided range, resulting additional overhead related to reading all clean pages. Optimize this by calling flush_cache_user_range() only on the pages that are already in the memory. Signed-off-by: Marek Szyprowski --- arch/arm64/kernel/sys_compat.c | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) -- 2.15.0 diff --git a/arch/arm64/kernel/sys_compat.c b/arch/arm64/kernel/sys_compat.c index 8b8bbd3eaa52..4a047db3fdd4 100644 --- a/arch/arm64/kernel/sys_compat.c +++ b/arch/arm64/kernel/sys_compat.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -32,23 +33,36 @@ static long __do_compat_cache_op(unsigned long start, unsigned long end) { - long ret; + struct vm_area_struct *vma = NULL; + long ret = 0; + down_read(¤t->mm->mmap_sem); do { unsigned long chunk = min(PAGE_SIZE, end - start); + if (!vma || vma->vm_end <= start) { + vma = find_vma(current->mm, start); + if (!vma) { + ret = -EFAULT; + goto done; + } + } + if (fatal_signal_pending(current)) - return 0; + goto done; - ret = __flush_cache_user_range(start, start + chunk); - if (ret) - return ret; + if (follow_page(vma, start, 0)) { + ret = __flush_cache_user_range(start, start + chunk); + if (ret) + goto done; + } cond_resched(); start += chunk; } while (start < end); - - return 0; +done: + up_read(¤t->mm->mmap_sem); + return ret; } static inline long