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