From patchwork Wed Mar 17 06:47:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 12144943 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, UNWANTED_LANGUAGE_BODY,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4E0AEC433DB for ; Wed, 17 Mar 2021 06:47:45 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E8D1C64F99 for ; Wed, 17 Mar 2021 06:47:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E8D1C64F99 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 6556C6B006E; Wed, 17 Mar 2021 02:47:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 605096B0070; Wed, 17 Mar 2021 02:47:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 480C86B0073; Wed, 17 Mar 2021 02:47:44 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0064.hostedemail.com [216.40.44.64]) by kanga.kvack.org (Postfix) with ESMTP id 2C5EF6B006E for ; Wed, 17 Mar 2021 02:47:44 -0400 (EDT) Received: from smtpin27.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id D4EBC81D4 for ; Wed, 17 Mar 2021 06:47:43 +0000 (UTC) X-FDA: 77928435606.27.BF85F76 Received: from mail-pf1-f175.google.com (mail-pf1-f175.google.com [209.85.210.175]) by imf24.hostedemail.com (Postfix) with ESMTP id 67C51A0000FA for ; Wed, 17 Mar 2021 06:47:43 +0000 (UTC) Received: by mail-pf1-f175.google.com with SMTP id y5so441416pfn.1 for ; Tue, 16 Mar 2021 23:47:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Z2s3MLc7lVR2IOVhQyaB46ZENq0pVAmLQYERUev4tS8=; b=STC4PfZiHVpNKjPp/wBdZTFbS2FNZOpteK5JbTyp9fFaa6jEPICe1UQe4Wfz1nqxy/ jFAHtsVSqS87+9fwZZPo/Atv8gYMYANzzBWJ/hkK0jmlJ97GSTEL7zO0VS3/IpHOa6l0 SiZtLnX//xEGfemP7GSboMQaBBmjzR+IU414MT83vUNRwGuSmzYnDDmW4fL1WkgHfxA3 gPV6jn3BmYWsM1yZOHlqrOeICYH4C43e4devT8VYyD86G02D61BdCkIB/b+O+mi4U1nl 7KycveB+Esg0vF20rgliDq5p50QyyaBd+uyhQdYTlgI1wGY8GxKq/ktMr6u3DhzSdQAj WBVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Z2s3MLc7lVR2IOVhQyaB46ZENq0pVAmLQYERUev4tS8=; b=Jmv4AzB6MM37qOVjQpTQTaM4H9XuO/3rH4K/YLNaYenlJkYIQbpHdkQXRMjveivfcU uSNDxHDF/5w0wdispJrnFenAUnfRy9SteEKoFOjka4flH5Uuh6bnGaE0yDKJy9u8LyNE 0PD0WMxOBHHjO9My+5hPsGIefqzqvC8CqxMUB0dYSYfPGYkDS9+f8zJo2e/WbD8QNfgW m/DffK2RgvcBUrrwAIsWmZbLCGTqkIS17/NteTcFHaCxddqHe+LOdcKe+3fen9g3a91+ JyqRqQcBlhEYkAOY1K7rj9dsBTVQVHHIfjinLq7RkhwZ+HcgNYRPNyU1Xf9VAc8qlwqR LiPQ== X-Gm-Message-State: AOAM533VeAR9z4/T3tLyKIOKUX/ntau0t0e8L8/bz54wD16YHEcvTmi5 x21gjxTGe7FHR7aY8/XBM4C3Zi/5LSA= X-Google-Smtp-Source: ABdhPJz64ODI3y2cn9mvQNHhL+ddr1j9LXqGhZR2yMS7w6RQnBNv2KxwH+7Y8rs9LevtWkJbhhz9vg== X-Received: by 2002:a65:448c:: with SMTP id l12mr1423974pgq.386.1615963661913; Tue, 16 Mar 2021 23:47:41 -0700 (PDT) Received: from bobo.ozlabs.ibm.com (58-6-239-121.tpgi.com.au. [58.6.239.121]) by smtp.gmail.com with ESMTPSA id x67sm19601345pfx.144.2021.03.16.23.47.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Mar 2021 23:47:41 -0700 (PDT) From: Nicholas Piggin To: linux-mm@kvack.org Cc: Nicholas Piggin , Peter Zijlstra Subject: [PATCH v2 1/3] mm: add __ prefix to page_cpupid_reset_last because it is non-atomic Date: Wed, 17 Mar 2021 16:47:28 +1000 Message-Id: <20210317064730.546507-1-npiggin@gmail.com> X-Mailer: git-send-email 2.23.0 MIME-Version: 1.0 X-Stat-Signature: adwwmppo3w7nngsfnooinbu3z3przwg6 X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 67C51A0000FA Received-SPF: none (gmail.com>: No applicable sender policy available) receiver=imf24; identity=mailfrom; envelope-from=""; helo=mail-pf1-f175.google.com; client-ip=209.85.210.175 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1615963663-487233 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: Add a __ prefix to indicate that it should be used in non-atomic situations (where the page is not subject to concurrent flags access, following the pattern of the other page flags modifications). This prepares for an atomic version. Signed-off-by: Nicholas Piggin Acked-by: Peter Zijlstra (Intel) --- Rebase only. Any comments on this idea? Thanks, Nick include/linux/mm.h | 6 +++--- mm/page_alloc.c | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index 64a71bf20536..086ab710383f 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1396,7 +1396,7 @@ static inline int page_cpupid_last(struct page *page) { return page->_last_cpupid; } -static inline void page_cpupid_reset_last(struct page *page) +static inline void __page_cpupid_reset_last(struct page *page) { page->_last_cpupid = -1 & LAST_CPUPID_MASK; } @@ -1408,7 +1408,7 @@ static inline int page_cpupid_last(struct page *page) extern int page_cpupid_xchg_last(struct page *page, int cpupid); -static inline void page_cpupid_reset_last(struct page *page) +static inline void __page_cpupid_reset_last(struct page *page) { page->flags |= LAST_CPUPID_MASK << LAST_CPUPID_PGSHIFT; } @@ -1449,7 +1449,7 @@ static inline bool cpupid_pid_unset(int cpupid) return true; } -static inline void page_cpupid_reset_last(struct page *page) +static inline void __page_cpupid_reset_last(struct page *page) { } diff --git a/mm/page_alloc.c b/mm/page_alloc.c index cfc72873961d..172368357e73 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -1266,7 +1266,7 @@ static __always_inline bool free_pages_prepare(struct page *page, if (bad) return false; - page_cpupid_reset_last(page); + __page_cpupid_reset_last(page); page->flags &= ~PAGE_FLAGS_CHECK_AT_PREP; reset_page_owner(page, order); @@ -1463,7 +1463,7 @@ static void __meminit __init_single_page(struct page *page, unsigned long pfn, set_page_links(page, zone, nid, pfn); init_page_count(page); page_mapcount_reset(page); - page_cpupid_reset_last(page); + __page_cpupid_reset_last(page); page_kasan_tag_reset(page); INIT_LIST_HEAD(&page->lru); From patchwork Wed Mar 17 06:47:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 12144945 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, UNWANTED_LANGUAGE_BODY,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0144CC433E0 for ; Wed, 17 Mar 2021 06:47:48 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7A3F464F99 for ; Wed, 17 Mar 2021 06:47:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7A3F464F99 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 19C1F6B0070; Wed, 17 Mar 2021 02:47:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1762A8D0001; Wed, 17 Mar 2021 02:47:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0397F6B0078; Wed, 17 Mar 2021 02:47:46 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0229.hostedemail.com [216.40.44.229]) by kanga.kvack.org (Postfix) with ESMTP id DCF666B0070 for ; Wed, 17 Mar 2021 02:47:46 -0400 (EDT) Received: from smtpin16.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 9F1CC8154 for ; Wed, 17 Mar 2021 06:47:46 +0000 (UTC) X-FDA: 77928435732.16.F2A4BFB Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) by imf15.hostedemail.com (Postfix) with ESMTP id 2E61FA0009D5 for ; Wed, 17 Mar 2021 06:47:46 +0000 (UTC) Received: by mail-pl1-f170.google.com with SMTP id f8so289040plg.10 for ; Tue, 16 Mar 2021 23:47:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=di77d9kyS/nFNfd94NlDShejODUp5JSu49zg1vaAHpI=; b=l3nD8hdj28avyhTrTf0dE44S6fcB7DtwlmkYLqwn2KRrLoCc/r5GoW36U2QExU+zmc XtgqP7wwJy+8nf93h2ozsVD8Yh1pCRe24RAKbZbWKQu6fgnLefHe6r6gUlWRysfO51+t gAyR3BeSuK+/f/qxs8NuNpipi5yIR4VwILDBGBM/WwrIVb5FCy9Eir4WYObF6aovQJ0M ALBN2B2IILQVrLH9AV6sQbNrvmACF/CnhyZPgpdTvE0Usi5OmCRbWTa4fQ7oBZG/z/Pb lC68xcEr0RqkqVreFVRTFnX1IqyCFfgwTaQ4IlkkyUBi1g2IPS+KxxD1hZXGBKkmXN5y 16vA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=di77d9kyS/nFNfd94NlDShejODUp5JSu49zg1vaAHpI=; b=RTcnFvDX2ay7TtYDnXlhIa4ngnveNHj1Jl3TVoYtd+rwrljtoeECD2iWTLp/nk0y7E 6xxUr1YN7lE2yhyswGuQhAX+5aLrJLI2f1hMM5qTn5Is0SgArHHvSTC6nblLJXkfV8wq rPtLWFU09XeRZNwnmMKDDhh/kqT/Je3fiDGhsSu3XVGCqFSFw4RNa8yVt8Id1ORTyJAV 4znksuE/DQXpzc44t7X+srEysCsedsA14PlfTlF81RXzbyO+Z89Gj0o/5CMoA6/gTkB0 gNh19WYnwnYZogtEq/pVXJe7eauNHuCetuwsOOpgjYKonx+dprI64mb7e8J4EsDvIXyo Qumw== X-Gm-Message-State: AOAM533aN1mA4x3O3txD8phudZTuk2v6ev1jDSB3Rjw/ASbACls9AFcg ChvQI2sIgdCiewI3bCmhJDzLeWX/mh0= X-Google-Smtp-Source: ABdhPJzWbtQQNczi5fyZ1G2Ns8Z33/t87fzn9yE/KWeWCRM3plpsFRneLdDW+HQVLjwXzno7216dyQ== X-Received: by 2002:a17:90b:1987:: with SMTP id mv7mr2908308pjb.152.1615963664958; Tue, 16 Mar 2021 23:47:44 -0700 (PDT) Received: from bobo.ozlabs.ibm.com (58-6-239-121.tpgi.com.au. [58.6.239.121]) by smtp.gmail.com with ESMTPSA id x67sm19601345pfx.144.2021.03.16.23.47.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Mar 2021 23:47:44 -0700 (PDT) From: Nicholas Piggin To: linux-mm@kvack.org Cc: Nicholas Piggin , Peter Zijlstra Subject: [PATCH v2 2/3] mm: add page_cpupid_reset_last atomic variant Date: Wed, 17 Mar 2021 16:47:29 +1000 Message-Id: <20210317064730.546507-2-npiggin@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20210317064730.546507-1-npiggin@gmail.com> References: <20210317064730.546507-1-npiggin@gmail.com> MIME-Version: 1.0 X-Stat-Signature: fbi5uq154u451y8qdanouoawepude66d X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 2E61FA0009D5 Received-SPF: none (gmail.com>: No applicable sender policy available) receiver=imf15; identity=mailfrom; envelope-from=""; helo=mail-pl1-f170.google.com; client-ip=209.85.214.170 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1615963666-187557 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: This can be used when there is concurrency on the struct page. If cpupid is not in page flags, it can use a store. Use this to replace the open-coded reset in wp_page_reuse. Signed-off-by: Nicholas Piggin --- include/linux/mm.h | 15 +++++++++++++++ mm/memory.c | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index 086ab710383f..2524553ea898 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1400,6 +1400,11 @@ static inline void __page_cpupid_reset_last(struct page *page) { page->_last_cpupid = -1 & LAST_CPUPID_MASK; } + +static inline void page_cpupid_reset_last(struct page *page) +{ + WRITE_ONCE(page->_last_cpupid, -1 & LAST_CPUPID_MASK); +} #else static inline int page_cpupid_last(struct page *page) { @@ -1412,6 +1417,12 @@ static inline void __page_cpupid_reset_last(struct page *page) { page->flags |= LAST_CPUPID_MASK << LAST_CPUPID_PGSHIFT; } + +static inline void page_cpupid_reset_last(struct page *page) +{ + page_cpupid_xchg_last(page, (1 << LAST_CPUPID_SHIFT) - 1); +} + #endif /* LAST_CPUPID_NOT_IN_PAGE_FLAGS */ #else /* !CONFIG_NUMA_BALANCING */ static inline int page_cpupid_xchg_last(struct page *page, int cpupid) @@ -1453,6 +1464,10 @@ static inline void __page_cpupid_reset_last(struct page *page) { } +static inline void page_cpupid_reset_last(struct page *page) +{ +} + static inline bool cpupid_match_pid(struct task_struct *task, int cpupid) { return false; diff --git a/mm/memory.c b/mm/memory.c index 5efa07fb6cdc..bb37dc0f4dac 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -2804,7 +2804,7 @@ static inline void wp_page_reuse(struct vm_fault *vmf) * unrelated process. */ if (page) - page_cpupid_xchg_last(page, (1 << LAST_CPUPID_SHIFT) - 1); + page_cpupid_reset_last(page); flush_cache_page(vma, vmf->address, pte_pfn(vmf->orig_pte)); entry = pte_mkyoung(vmf->orig_pte); From patchwork Wed Mar 17 06:47:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 12144947 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 070B0C433DB for ; Wed, 17 Mar 2021 06:47:51 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 8ED7764F99 for ; Wed, 17 Mar 2021 06:47:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8ED7764F99 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 3208E8D0002; Wed, 17 Mar 2021 02:47:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2D1AF8D0001; Wed, 17 Mar 2021 02:47:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 199F08D0002; Wed, 17 Mar 2021 02:47:50 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0009.hostedemail.com [216.40.44.9]) by kanga.kvack.org (Postfix) with ESMTP id 0034D8D0001 for ; Wed, 17 Mar 2021 02:47:49 -0400 (EDT) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id A4129181AF5D0 for ; Wed, 17 Mar 2021 06:47:49 +0000 (UTC) X-FDA: 77928435858.17.B06A045 Received: from mail-pg1-f179.google.com (mail-pg1-f179.google.com [209.85.215.179]) by imf13.hostedemail.com (Postfix) with ESMTP id 357D3E0001AF for ; Wed, 17 Mar 2021 06:47:49 +0000 (UTC) Received: by mail-pg1-f179.google.com with SMTP id q5so11555453pgk.5 for ; Tue, 16 Mar 2021 23:47:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=G12rUxYBu8wlvZ4WjMwGP7wOGBWxJVaE5vDIbdrxKNE=; b=hD/dr2p7IlYrxQGY1O8u86FfkVD/ki8NTxx1Wh2tLGhnJcX7G4ATz/OUKgxUJ4i9n3 CgmE88ZRUVBrdAZHHUFkJK2RpfRmDnxfRWgK1CogSRyTsJBhAKUXdccqEmM0p0fzjAgp bLA7yD2JKfWJsTntDq2zEP5rIkLr2K+a0Afeowo1SoMz8x7Ti58rqDFfJspIMXJfUI+/ N5K42arFW3Qzdjkj5fqPMZakrlBpoToZq+koopNHiFMfCBZxbkEgWdh8Q5Ue+IY9Axoq rOQVy9mxoObLPwklWTxYVogRKZLwNQ8xWzrqD9MujyxS9REF0NoODIp17lJoqvcknyIf QREg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=G12rUxYBu8wlvZ4WjMwGP7wOGBWxJVaE5vDIbdrxKNE=; b=AsMFd4ABk4Oz3KrLZ7UAq3i+BCKdz/g0ztw4Lc2vAcc4mQE/HDidrTgAkKrjIQ2eT/ NHPTj8wlQjdKopLDB24qK4d+sewmyJbN/9BYwMdmet7/raqRfIQcH4/igAyAnCoDkXGp dS7kSGdpidkYgCNtQAOu9HD6XBd04Uda4kmlc6Jt1genLTqvv4TRQSLBCqsWjfgdyfFg 2TdWIf2Z/kv5ubEi1aDhiVd256do+CkoaWpWvVzXuH57yL8ibcdb7I8ssRGj+j2XOFr+ WQoHvI2WIVTMv6d+IsgjOX94SuIM79DN73zcg7KHtXo1yYqNpucp9bac2L0ZV63dMbL6 k+eQ== X-Gm-Message-State: AOAM530fvBrWjYkLTKOAosLHOjY4OyoHYiGtwc2LPkeHClazYTns6oIZ cVC2m7A3YBT6qNCJVFGbCMea00UFlyo= X-Google-Smtp-Source: ABdhPJxCasdHNCfd0CY6Z3ceFfAW7j+eUFSBC+vI7dT/mxXbPvZOibgsD01XiyCIy8XqHsDrxHPyUw== X-Received: by 2002:a63:2e87:: with SMTP id u129mr1397466pgu.107.1615963668050; Tue, 16 Mar 2021 23:47:48 -0700 (PDT) Received: from bobo.ozlabs.ibm.com (58-6-239-121.tpgi.com.au. [58.6.239.121]) by smtp.gmail.com with ESMTPSA id x67sm19601345pfx.144.2021.03.16.23.47.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Mar 2021 23:47:47 -0700 (PDT) From: Nicholas Piggin To: linux-mm@kvack.org Cc: Nicholas Piggin , Peter Zijlstra Subject: [PATCH v2 3/3] mm: skip page_cpupid_reset_last atomic update if the value is already reset Date: Wed, 17 Mar 2021 16:47:30 +1000 Message-Id: <20210317064730.546507-3-npiggin@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20210317064730.546507-1-npiggin@gmail.com> References: <20210317064730.546507-1-npiggin@gmail.com> MIME-Version: 1.0 X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 357D3E0001AF X-Stat-Signature: x3anzrdn6ztyfdets4fggoq75kyxbdzm Received-SPF: none (gmail.com>: No applicable sender policy available) receiver=imf13; identity=mailfrom; envelope-from=""; helo=mail-pg1-f179.google.com; client-ip=209.85.215.179 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1615963669-119965 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: Improves performance of a PROT_READ -> PROT_READ|PROT_WRITE -> store microbenchmark (which goes via the wp_page_reuse fault path) by about 10% on a POWER9. Signed-off-by: Nicholas Piggin --- include/linux/mm.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/linux/mm.h b/include/linux/mm.h index 2524553ea898..1e1471235055 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1420,6 +1420,9 @@ static inline void __page_cpupid_reset_last(struct page *page) static inline void page_cpupid_reset_last(struct page *page) { + if (page_cpupid_last(page) == (-1 & LAST_CPUPID_MASK)) + return; + page_cpupid_xchg_last(page, (1 << LAST_CPUPID_SHIFT) - 1); }