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: 10185445 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 95D9C602C8 for ; Fri, 26 Jan 2018 11:20:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5276628837 for ; Fri, 26 Jan 2018 11:20:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6B96F2919F; Fri, 26 Jan 2018 11:15:32 +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 C7F5029188 for ; Fri, 26 Jan 2018 11:15:31 +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: In-reply-to: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:List-Owner; bh=LkhycSqYCVWj6yY5OtDdySx40EaG5YBApwhRgUCncQw=; b=BjMQkEns63aHXxw0uSI5IN2ymY I9g9grX+NZRFEbLHLWUE5DE2TOE13bUSWZTTG+4Q1Y/9BKxKFOVXFd1klEXjmwnajA2RsZKDs+4jD ImpegEp9JOYipKZgSPvpiA7URmYbpjTVU7NeGzHFtZyBZmF139Q/4EjXyieASZXqT5O8gT0zN691t c6bQcsuzvjnEKYFZOt0Y/JxTe4DQoIT2+3QIX3Ahw+5mkNrsrrNRAzWB091HgpbGTtwUTNCUEzQ6c 4ojV97bejyIvWQFmO8ADGv21zQ0R5JUHzMPFlUPS61vLFVqDYkU/MwoQgs0aFrp788gpBgt7OIBeS X3/uApNQ==; 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 1ef1yk-000459-5R; Fri, 26 Jan 2018 11:15:30 +0000 Received: from mailout1.w1.samsung.com ([210.118.77.11]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1ef1yQ-0002Vr-Pl for linux-arm-kernel@lists.infradead.org; Fri, 26 Jan 2018 11:15:14 +0000 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 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 FpPuT2Cx2PT4GqvF5V1z2CzWHrnLbrH5w0s2i5cfT7A4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vWuA4vzCthKbP65kQlimbzE4u87wWo4Bewkbl54wQ6xzFaiY/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> 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 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(-) 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