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: 10185443 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 87D7A60211 for ; Fri, 26 Jan 2018 11:15:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6D86C29188 for ; Fri, 26 Jan 2018 11:15:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 60E382919F; Fri, 26 Jan 2018 11:15:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id AB31A29188 for ; Fri, 26 Jan 2018 11:15:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: Message-id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:List-Owner; bh=H9wMneZbAsT7qsc1Ntb1fzfmEVvqUuw/ZH8tkOF+EGI=; b=tH EyEMCwLWUlWQge4PBjJ54pirhs0sqHyAPGAnl0FGbd3PbVCvNWJ/4OtN4B3juqxfvgpVSFdI9z5I2 8V2rnDYP3HwQ1KA3Fn2Tt0Yp5GKptcKTQEPflkwPxE4fsQswf2C/XWJkFMkJkmI2UwNby99hkrxuf oPTw1dUusIKLV6P0/h+jSDqFpyTpuXWwv+uvj2rJLHcNzNo0/YumsHlsTJ/xX7vm3dtyXBsr4tJa6 MiAK8TWgj6fYvqRmzWxxyvJm1jt9uULOJ/PIJ3OCsZaeUW5L1iLV6Tmg3GpFSZCnud1Q4MKEPlCIx lfUdIikcWpzGPYHOHoyy2gexbhTIbFKQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1ef1yU-0003nw-Fo; Fri, 26 Jan 2018 11:15:14 +0000 Received: from mailout2.w1.samsung.com ([210.118.77.12]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1ef1yQ-0002Vq-Pb for linux-arm-kernel@lists.infradead.org; Fri, 26 Jan 2018 11:15:13 +0000 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 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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2Ar0XhnKdQ2eYnF33eyTWDkXsDIsIpRJLW0ODc9 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: X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Bartlomiej Zolnierkiewicz , Catalin Marinas , Will Deacon , Inki Dae , Russell King , Marek Szyprowski MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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(-) 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