From patchwork Sun Dec 20 05:03:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 11983785 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 D3E61C4361B for ; Sun, 20 Dec 2020 05:03:49 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 66F4923A5E for ; Sun, 20 Dec 2020 05:03:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 66F4923A5E 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 BC5CE6B006C; Sun, 20 Dec 2020 00:03:48 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B75D46B006E; Sun, 20 Dec 2020 00:03:48 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A8B626B0070; Sun, 20 Dec 2020 00:03:48 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0189.hostedemail.com [216.40.44.189]) by kanga.kvack.org (Postfix) with ESMTP id 9175C6B006C for ; Sun, 20 Dec 2020 00:03:48 -0500 (EST) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 5EF5F2485 for ; Sun, 20 Dec 2020 05:03:48 +0000 (UTC) X-FDA: 77612468136.18.news11_4a0d71f2744c Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin18.hostedemail.com (Postfix) with ESMTP id 429E7100EC66B for ; Sun, 20 Dec 2020 05:03:48 +0000 (UTC) X-HE-Tag: news11_4a0d71f2744c X-Filterd-Recvd-Size: 4978 Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) by imf42.hostedemail.com (Postfix) with ESMTP for ; Sun, 20 Dec 2020 05:03:47 +0000 (UTC) Received: by mail-pl1-f182.google.com with SMTP id x18so3848364pln.6 for ; Sat, 19 Dec 2020 21:03:47 -0800 (PST) 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=um3GEUdqzNszh1+HQm5SSjtl5vXSxHuezM43UcyqtVE=; b=gQTbJF0+wr9JXX7koccIZDtkaCN9P0kW0l43rWJhdrMYA2+98YaMAKuT9CVGVTbMYq nqSG1g2KK+PtSuapnTFr71xNitgXo4CaIPLtAFdZ0FhyI9ZXglffldywzTMyzYmF7aVV Bt8WcBt8fqJ0x2LEryGJq7eHXOk56Empqi4269h51/liggKVVRPpoEUkHFx8LJJn62/k QvGS8iHeaLU9QMg0uYvA+1qnCq/NoWBBWVjnL9cjC7YxcimHdB6UL6j2hYNFO9sow3MS +Ruva+k+Hiz1Z3LCBJicMVXqmrM8rG+lAgd0skbl76N65BxyTzk8dMGludcivMYjUWIo iSog== 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=um3GEUdqzNszh1+HQm5SSjtl5vXSxHuezM43UcyqtVE=; b=trlzbSMuiPU5s4+u/Ch+L9e744U/g8JsuHRpVqUDGSP3QvsXkA3uShJ6tP3d2FPJIk rUMuCsxS6oPfHxkG7294Ocn57vPmmrUgTef+jKzM3KFtdZSgxqJjx6TNkaLWKd9mH1bE xW7zN/kGtRsjP+lC8zvMVdxRozDGFVGVOSZ3Ld9X0WTpmjuicFfylOaokZ6phEV2v8dH B/S17IDFgi0m3zTvWEBNBITBHmIRVltEeAOySmM7W6/R6mQ/9zi6mXtOsUB0N+TjiJFZ jJkwNuhTI5tlLGP9V5FIHcDPDlbdG30w2tOBQtTAErlOcNlDTCawNdK/9snNG8UdPmN3 oSVw== X-Gm-Message-State: AOAM531B7o97pP6MjYDuulU85KC0EfHjGi7HN1LHKkkD+u34p7ffLSVZ see2Hr4PXcbFK8scUUAZ0lAFPYd2eYE= X-Google-Smtp-Source: ABdhPJzt3JPd1uRyQbEVq70ryeU4DCWg6zRU8ntl7rPHc1n4inC/VQMd9lYXunZkT8eBTpOCjGopyA== X-Received: by 2002:a17:902:a512:b029:db:cf4c:336b with SMTP id s18-20020a170902a512b02900dbcf4c336bmr11143934plq.17.1608440626947; Sat, 19 Dec 2020 21:03:46 -0800 (PST) Received: from bobo.ibm.com (193-116-97-30.tpgi.com.au. [193.116.97.30]) by smtp.gmail.com with ESMTPSA id a23sm11625185pjh.19.2020.12.19.21.03.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Dec 2020 21:03:46 -0800 (PST) From: Nicholas Piggin To: linux-mm@kvack.org Cc: Nicholas Piggin , Peter Zijlstra Subject: [PATCH 1/3] mm: prefix page_cpupid_reset_last as non-atomic Date: Sun, 20 Dec 2020 15:03:38 +1000 Message-Id: <20201220050340.849754-1-npiggin@gmail.com> X-Mailer: git-send-email 2.23.0 MIME-Version: 1.0 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 --- 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 855161080f18..5b3fc2c8fd8b 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1358,7 +1358,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; } @@ -1370,7 +1370,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; } @@ -1411,7 +1411,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 3beeb8d722f3..ead28946f3ce 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -1260,7 +1260,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); @@ -1453,7 +1453,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 Sun Dec 20 05:03:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 11983787 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 62ABFC4361B for ; Sun, 20 Dec 2020 05:03:52 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E3730233E2 for ; Sun, 20 Dec 2020 05:03:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E3730233E2 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 70E316B006E; Sun, 20 Dec 2020 00:03:51 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6E2E46B0070; Sun, 20 Dec 2020 00:03:51 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5F76D6B0071; Sun, 20 Dec 2020 00:03:51 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0020.hostedemail.com [216.40.44.20]) by kanga.kvack.org (Postfix) with ESMTP id 480BC6B006E for ; Sun, 20 Dec 2020 00:03:51 -0500 (EST) Received: from smtpin04.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 0D201824999B for ; Sun, 20 Dec 2020 05:03:51 +0000 (UTC) X-FDA: 77612468262.04.lunch69_4110ba92744c Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin04.hostedemail.com (Postfix) with ESMTP id E9C25800EFDE for ; Sun, 20 Dec 2020 05:03:50 +0000 (UTC) X-HE-Tag: lunch69_4110ba92744c X-Filterd-Recvd-Size: 4969 Received: from mail-pj1-f42.google.com (mail-pj1-f42.google.com [209.85.216.42]) by imf03.hostedemail.com (Postfix) with ESMTP for ; Sun, 20 Dec 2020 05:03:50 +0000 (UTC) Received: by mail-pj1-f42.google.com with SMTP id lj6so4297964pjb.0 for ; Sat, 19 Dec 2020 21:03:50 -0800 (PST) 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=mlVbCPwoNrfW6cjE2V8EB9QCL2g3Vy4Qw8GvHG/LcAU=; b=URb3Vg9SdwTZBOiLK8y88RsF5HESBOEz9rbiZcKi+TeiIG2Cmwmb3+6k/mJzrJyucR nxAuCR7m3ir4jinS5FWhpwE2mnWny8MviPbjFkUku6u/L4EnfmCh+AdBO8JmJbdjhZAh jR5zVOarmDTAwPSrBblKSuRPduAtsOGSpcxNWQ6z6rCLwpWbZscsjb/+1MtLMF4I9DFu 7adHzcgP1YQpkx5hw2njjC6fE0/Yp6kQ4Nwf3il5MPpBJf0rpEG9QuJi5fOS9ud8RlUw +dXZJLXBlfTb8Za1CMbMlurz9n61xExLBD6VRPLBPyhTImvNr58HG8G4pj3+B/+133jb QPQQ== 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=mlVbCPwoNrfW6cjE2V8EB9QCL2g3Vy4Qw8GvHG/LcAU=; b=sXtFjmR1BxoelY8gtx+C5IV8KF60Nn9jA7LfoID8VVEXaPbUQIYNb84yZUXkk7alpM xyMsudn88rFqKt1TIKIY3p9rWN1EfKJyRVcOcn0NupFv9hZFty4N2txDl2W/a+L8d2UF a2VVQpCFBlX3IL/nqBM/InPdVKUVeAfkwnFBoOlHB5flIm9wB8hL2QL6NAYZfeD1MszX e8BhRZRBysQmZ9Rzmtoj1w4f8tNuCHeaqbOWafXjSYH+iG/UzYqDNUxOuz/L40elS90J m/H4ZMINMiCEvG3ijo+Ej3qSFftXfLsV65zLIqib8Y0KLS3dV4JIRSNHMbZ26MMbGeRB hC2A== X-Gm-Message-State: AOAM532SMxVyn1T3fIU6Hm0GePKxkT+JtbPu14w5tBrwcgEC4x8APeac /4GtrNHPgfbYChkrKgWvwbB4gSa2UFQ= X-Google-Smtp-Source: ABdhPJzJPAIKwJg3emFRVbBHkaSjJnN+CldO+4Ye80pA9M365q6ymCzFvoOLJlBuoUPAGIPPKIhvXw== X-Received: by 2002:a17:902:b282:b029:da:fd05:7766 with SMTP id u2-20020a170902b282b02900dafd057766mr11016197plr.52.1608440629500; Sat, 19 Dec 2020 21:03:49 -0800 (PST) Received: from bobo.ibm.com (193-116-97-30.tpgi.com.au. [193.116.97.30]) by smtp.gmail.com with ESMTPSA id a23sm11625185pjh.19.2020.12.19.21.03.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Dec 2020 21:03:49 -0800 (PST) From: Nicholas Piggin To: linux-mm@kvack.org Cc: Nicholas Piggin , Peter Zijlstra Subject: [PATCH 2/3] mm: add page_cpupid_reset_last atomic variant Date: Sun, 20 Dec 2020 15:03:39 +1000 Message-Id: <20201220050340.849754-2-npiggin@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20201220050340.849754-1-npiggin@gmail.com> References: <20201220050340.849754-1-npiggin@gmail.com> MIME-Version: 1.0 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 5b3fc2c8fd8b..6ece500464e0 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1362,6 +1362,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) { @@ -1374,6 +1379,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) @@ -1415,6 +1426,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 7d608765932b..990e5d704c08 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -2798,7 +2798,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 Sun Dec 20 05:03:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 11983789 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 B6239C4361B for ; Sun, 20 Dec 2020 05:03:54 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 55A10233E2 for ; Sun, 20 Dec 2020 05:03:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 55A10233E2 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 EB0276B0070; Sun, 20 Dec 2020 00:03:53 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E357B6B0071; Sun, 20 Dec 2020 00:03:53 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D28F86B0072; Sun, 20 Dec 2020 00:03:53 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0004.hostedemail.com [216.40.44.4]) by kanga.kvack.org (Postfix) with ESMTP id B644B6B0070 for ; Sun, 20 Dec 2020 00:03:53 -0500 (EST) Received: from smtpin30.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 6EC3B824999B for ; Sun, 20 Dec 2020 05:03:53 +0000 (UTC) X-FDA: 77612468346.30.shade95_4904d692744c Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin30.hostedemail.com (Postfix) with ESMTP id 5590D180B3AA7 for ; Sun, 20 Dec 2020 05:03:53 +0000 (UTC) X-HE-Tag: shade95_4904d692744c X-Filterd-Recvd-Size: 3714 Received: from mail-pj1-f42.google.com (mail-pj1-f42.google.com [209.85.216.42]) by imf14.hostedemail.com (Postfix) with ESMTP for ; Sun, 20 Dec 2020 05:03:52 +0000 (UTC) Received: by mail-pj1-f42.google.com with SMTP id l23so4518667pjg.1 for ; Sat, 19 Dec 2020 21:03:52 -0800 (PST) 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=eTtGfwmtISRbmkA52dcEacoFKDkkBe8Yu/+QuY7wSPw=; b=p0d0KQy6HqFzlhSUzQFABMGvp1vl6Jc+xuhwDiawwmrsc2dTtnXfiNAVkkAa4w1iRN ZdNaDm6OFbEAlOkU3rPhR7ViJgGNt2SDAO3Rj/nia1ajbWBJuVWwAUbEN37lZ/MXIUr7 gZ/cBamedNQ+Ek01WR9GK9zsDz6bFkVY9KEzeHV2UmcnBj8YxeEkiH8F3TJVtOQPWUPo wN0I6bZLtP+hkbpj8/17K6YF5a8BQcdv1VTfeD7rEJQgEVVTrIPzLdPqoNhCtWf7iLia G6W3VOLwmajp5GjQTEgtQwVE7955Rhwb1DNoIlgTpc20vUvSrGp4c8gyWhUsn7zBqcF9 nc3Q== 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=eTtGfwmtISRbmkA52dcEacoFKDkkBe8Yu/+QuY7wSPw=; b=KsC3gbzJ668DM+sqER4JT2uwmawLO18vL6t4QFmaeQ+uHBI4Efy9Ecdhdjb9q7j2Tg Uaph9Ecq860CECt8vQPYHBj1JkvRKN0vawhC+cj3W/tIv/IyjjrIdz+Yb6ez7JYccJrD d+YrYLxiovM/IPFiUDWRh29xhNVzzX8cPmdbsBK2hcsScn7Sn2FF8zeE09B/+RnxwA6M ppp0WEOarkJOfuZhJi3a/uWBIzc7DuWyIqoFw1TvMnTakE18NA6Nh4PTQKk1ZdSYe8g+ zz6Wsgj16EObR7lsLq5fHqPIxe3avRWUxoj5iCgOmjgyKy14rf/Amuokz5NrXgWfE8b7 tnPA== X-Gm-Message-State: AOAM5336IkS9z/hlezyownXm4qyyAdwpaRILW+hFvVCZK1WxwhyQQ+3D zdLrOedDnvDGJ1gl0QrVLbsI6d6fz/U= X-Google-Smtp-Source: ABdhPJzrDV7x52odBKdmlD+s3BKDPflwaZDSp9uClYZTKuLZDjvj1+PHLmp47gRgSTUO18Lc5hpLIQ== X-Received: by 2002:a17:902:6b45:b029:d6:c43e:ad13 with SMTP id g5-20020a1709026b45b02900d6c43ead13mr11092879plt.77.1608440632098; Sat, 19 Dec 2020 21:03:52 -0800 (PST) Received: from bobo.ibm.com (193-116-97-30.tpgi.com.au. [193.116.97.30]) by smtp.gmail.com with ESMTPSA id a23sm11625185pjh.19.2020.12.19.21.03.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Dec 2020 21:03:51 -0800 (PST) From: Nicholas Piggin To: linux-mm@kvack.org Cc: Nicholas Piggin , Peter Zijlstra Subject: [PATCH 3/3] mm: skip page_cpupid_reset_last atomic update if the value is already reset Date: Sun, 20 Dec 2020 15:03:40 +1000 Message-Id: <20201220050340.849754-3-npiggin@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20201220050340.849754-1-npiggin@gmail.com> References: <20201220050340.849754-1-npiggin@gmail.com> MIME-Version: 1.0 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 6ece500464e0..c0a9e8de0738 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1382,6 +1382,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); }