From patchwork Fri Mar 17 21:58:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Stoakes X-Patchwork-Id: 13179523 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id AA7DEC74A5B for ; Fri, 17 Mar 2023 21:58:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 059AE6B007E; Fri, 17 Mar 2023 17:58:36 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 00A4C6B0080; Fri, 17 Mar 2023 17:58:35 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E146F6B0081; Fri, 17 Mar 2023 17:58:35 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id CF0566B007E for ; Fri, 17 Mar 2023 17:58:35 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 98FC2C06ED for ; Fri, 17 Mar 2023 21:58:35 +0000 (UTC) X-FDA: 80579754990.18.4BCFCE4 Received: from mail-wr1-f50.google.com (mail-wr1-f50.google.com [209.85.221.50]) by imf07.hostedemail.com (Postfix) with ESMTP id D08804000E for ; Fri, 17 Mar 2023 21:58:32 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=GesoOYtk; spf=pass (imf07.hostedemail.com: domain of lstoakes@gmail.com designates 209.85.221.50 as permitted sender) smtp.mailfrom=lstoakes@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1679090312; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=d5Vf9hPk4TijoCslag2qu8Bydr8Y3MLZgxsiyraFWDI=; b=FeCU4v2h9dEQv1u+61lcL48ix1iphA7I+p8VZ6Nqfi/Xgj0S4DiFtUIKyiNdQjWWiR3mtF cBT6N9SB7LzfoDSASX0+vKxeaFaYPonNq08lSHWY7yDoCTaey59IEt2k15kb/ys9f38KhG G8O9tFpK1N5Y5Je8KQNpOc8RgXiBCC0= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=GesoOYtk; spf=pass (imf07.hostedemail.com: domain of lstoakes@gmail.com designates 209.85.221.50 as permitted sender) smtp.mailfrom=lstoakes@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1679090312; a=rsa-sha256; cv=none; b=1sj6SlkcIeFMK1TjJGsmylpc4boLMtQoage3yB7J7x+uM1lzEjpU715ljCQaMgAR1+ojcq GBNxf+3YVjr+6loDRn7q056hXpnl8hfTHwjWJO4kC3Y2KJGkVbqhcJfXO7/O8pCjF+biEi y+yw1UxxlptA0pbCsdc34vHHpbsa9nw= Received: by mail-wr1-f50.google.com with SMTP id t15so5637728wrz.7 for ; Fri, 17 Mar 2023 14:58:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679090311; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=d5Vf9hPk4TijoCslag2qu8Bydr8Y3MLZgxsiyraFWDI=; b=GesoOYtkRvZvc8UDZKdCOVv0bjs87Z0DM/cCHzjncbj1wX0MSojd2K6jf+QesOuh5Q kZCmczsOpxAvQxJ/szlpbti5EhBsTBHiB8u5bpuRmtYYcTJAjo9FTQACwgEcjoEffI13 9zI+fXO1DsSlQnmy2LnosY9x9FRHintSA5ITqXFnLW/ta0bMBArTS9ybGrRmbc3+GkLt XGPZrxMgyHGMLYdJ/0byP30lidX6IHuMG+51aEfrZVqs6+m+Q/VdSjwtAX/jaUXhoFDT bLm+KGk5Mksuz/kRewHry8LFRV6rodlbgmrXtijDCcxwKp5lCtWckhzm+U5QQwwmP9EQ 37Pw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679090311; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=d5Vf9hPk4TijoCslag2qu8Bydr8Y3MLZgxsiyraFWDI=; b=ZF9FK+xVQXaF6gmrIfxVTXQueiWyBm56sL581mqnc8NmgxNRLXutIiwjB6bG0puzwr WR9gO5SNk5Sr0yW1HSD2DOodAR+179x0j+t0Gl79GtJOLHdMzfHoRYYeKbooFpE486xc W96EYXg7MCxtUM1r9L6GUNaCmUBFcxbVo3ViXGNtEshB1mA0SFe0Xge9wxmFVHrUGxyv luwD0nZNqIHyrEFM7UT4Q6tnBBvjMur2VhNBMPqMoXBajpgnnWj+cPtweimJCJyU56/o 48MScXxNMZCm9HIaquUZfnqqW04EQWU/vgfBOd1O+TGldSUwN7CwSrIugeeL3BN88VCS Iz3w== X-Gm-Message-State: AO0yUKWYIaePj0ikKzLEkjTRS7dypWR9UISny6+gfB/PRCAJrAoPH6iT JrmiF0OwdtLqcRSMsCIiDsinyMg6L+Q= X-Google-Smtp-Source: AK7set/0giHP1Q0iPR9xqaXyDpTJ/ztJWRNNYrWVJ0+w4kQpByF/HxcMY6MvBXLY5FhRiRmI///LxA== X-Received: by 2002:a5d:6944:0:b0:2c5:4c9d:2dab with SMTP id r4-20020a5d6944000000b002c54c9d2dabmr3807112wrw.10.1679090310797; Fri, 17 Mar 2023 14:58:30 -0700 (PDT) Received: from lucifer.home (host86-146-209-214.range86-146.btcentralplus.com. [86.146.209.214]) by smtp.googlemail.com with ESMTPSA id c9-20020a5d4cc9000000b002d21379bcabsm2849757wrt.110.2023.03.17.14.58.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Mar 2023 14:58:29 -0700 (PDT) From: Lorenzo Stoakes To: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrew Morton Cc: David Hildenbrand , Matthew Wilcox , Vlastimil Babka , Lorenzo Stoakes Subject: [PATCH 0/2] Refactor do_fault_around() Date: Fri, 17 Mar 2023 21:58:24 +0000 Message-Id: X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: D08804000E X-Rspam-User: X-Stat-Signature: dchwpk4pkteycmso9p1orzjkjjxu7pbu X-HE-Tag: 1679090312-523935 X-HE-Meta: U2FsdGVkX1/Rj0SC2MXkcBRa7aS/XD2XMY9r292KLZt+Vp8HZAVB7O031hhBioJgeNM33TN6gReuNGUbZeeBJuh63EAyK/sylutn1D2vOJTA3D411V9UKtsahVpy/CTA4lBbF9pXrrCrDc3hu2fwWwHNumpW7otkImenQkftHBmELFn3zfZdu0WcdniGgS5n4H4ZlpIlDzL3r+HdjSbtX4TdJ1+PjUnuXFbqhm49NTvN9sPlpdqVXAZkYMTc4GQhpDHnkApSSSA5XJsnyWtsNj1bxASUJAPfr8wA2KyLgRYSHGVev6rMQBVODXIjuCdUedXH0XwgS7+mQjVTPp+OW8JyCin8OhqrZRcwjykDJDSOy1tpxcJcH6SdXkglGGwPpdFUs7ww33fGGzfKtJJbso+WMv4hupa1wF+vP8ibB5FC2WMbY5/SSctU8hcOPGhvFhgtJ42H3qp1KsvzBnZJiForPQmKgGDDXqezFvZgfZg9Ra6n9Nn7466pv0N9VDTproRQ22GePdmxDoK0SMpFAeoPJ6LplAsLHg4Hgw7ii2bDqNZlZ1+M4r1KnLFJzMrzC/4oSPchXHA0/ZgIZyfklLQ1q0DIfNcOOtZyULDUkbdQWUr5QZsuUh4ffPV33VjpXIc4kObmrIGEjw8pXdc92vQRdTWj6/IG2gxnkKYlbGdImciSC41o/0OCr0tqgO+h2OiQV51CWWkIZgFvV+O80aE4Wcra7mpH78vaDNFK3CQG68mZfdSXyPK5Rfe11JTLayxWCjbJKZPoOXB5sJ6oFxSLlJT8946J0ukWr3Hd070kwnyZRa1wu01y6d0P8ZR8Wff6G8qud4NSFRB3w+YK+Zjo35yRBkDaHt2Gxrdoz/avLkzyGixEkjGSabmcWb2RWiHSCewwXMr7h0uIfm2XcJW8FE+/YudQBSnT7qBoRaMfXi83XaMSkdUB6WSwyH8CR+xh382FkLgir0MfwWV Y03eqoEG 0KjsXrl8rL8VSpKnl2f9GHIF41j+XfLXFfGigbx3HrPq3M6obHe/aOIqpS+XpG+nbWug2frK8NuiFcVNiMPwIbDToKpQhjVesNFbg7zqATn2mQL1tpztOlBJjMcg0NGO04mogpEJMx9F60/ZfPAPjeEhekrfJ+yIxfvzje/utY7LBUS7lIc/1W7rSK5Q4+ndZtrz+lY0fVXVJwPMxGHU6gpSe9M8a4kXp5FdMq/zoKzoGTGiE2W+TGDtP1Al3Kvp0wOsn6ExYHkhfU2nWf3+Pxi2+ovV2LF2xv7SAoyR8DFBcwhAyPbBB1HXVjAzdwGIak5X7zGZooy4RxJtFhBKgxNlcOu2KOQZJ+lWAQsUhOpXrW/7zGUM8OGSNJsDhm7Jtg1MbhseJPjNtikFmBCDEjIT4beQQHWpRyZVnO5bvxVxw6sjWHqcENJaWVHNO5ITHMbWMf1ZzOu0fhg/9VFa6SAUj/nLvlTbly/4bw3eey41iF2s= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Refactor do_fault_around() to avoid bitwise tricks and arather difficult to follow logic. Additionally, prefer fault_around_pages to fault_around_bytes as the operations are performed at a base page granularity. I have run this code against a small program I wrote which generates significant input data and compares output with the original function to ensure that it behaves the same as the old code across varying vmf, vma and fault_around_pages inputs. Lorenzo Stoakes (2): mm: refactor do_fault_around() mm: pefer fault_around_pages to fault_around_bytes mm/memory.c | 62 ++++++++++++++++++++++++++--------------------------- 1 file changed, 30 insertions(+), 32 deletions(-) --- 2.39.2