From patchwork Mon Oct 19 10:15:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muchun Song X-Patchwork-Id: 11843933 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 13C3D16BC for ; Mon, 19 Oct 2020 10:17:34 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 557D322268 for ; Mon, 19 Oct 2020 10:17:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=bytedance-com.20150623.gappssmtp.com header.i=@bytedance-com.20150623.gappssmtp.com header.b="r/hMWlZ4" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 557D322268 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=bytedance.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 434466B005D; Mon, 19 Oct 2020 06:17:32 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 3E43F6B0062; Mon, 19 Oct 2020 06:17:32 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2D2516B0068; Mon, 19 Oct 2020 06:17:32 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id F27AB6B005D for ; Mon, 19 Oct 2020 06:17:31 -0400 (EDT) Received: from smtpin08.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 98D591EE6 for ; Mon, 19 Oct 2020 10:17:31 +0000 (UTC) X-FDA: 77388273102.08.anger67_5f108e327236 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin08.hostedemail.com (Postfix) with ESMTP id 5E35A1819E76F for ; Mon, 19 Oct 2020 10:17:31 +0000 (UTC) X-Spam-Summary: 1,0,0,d27fd7070e448799,d41d8cd98f00b204,songmuchun@bytedance.com,,RULES_HIT:41:355:379:541:800:960:973:988:989:1260:1311:1314:1345:1437:1515:1534:1541:1711:1730:1747:1777:1792:2393:2559:2562:2907:3138:3139:3140:3141:3142:3352:3865:3867:3871:4321:4605:5007:6261:6653:8957:10004:11026:11232:11473:11638:11658:11914:12048:12114:12296:12297:12438:12517:12519:12555:12895:13069:13311:13357:13894:14096:14181:14384:14394:14721:21080:21444:21450:21451:21627:30054,0,RBL:209.85.210.195:@bytedance.com:.lbl8.mailshell.net-62.2.0.100 66.100.201.201;04yrgrsdp5nnkzx71ooudhj3iwbfoyc4w87bymhjyotc6najfzzfqkpasr3bf5b.deg9rm8zoxxk98z6rehcbn8antdaaqg1y6q8trqqbx8cbitpqe4crh7h4j5n7fx.e-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: anger67_5f108e327236 X-Filterd-Recvd-Size: 4431 Received: from mail-pf1-f195.google.com (mail-pf1-f195.google.com [209.85.210.195]) by imf25.hostedemail.com (Postfix) with ESMTP for ; Mon, 19 Oct 2020 10:17:30 +0000 (UTC) Received: by mail-pf1-f195.google.com with SMTP id c20so5729943pfr.8 for ; Mon, 19 Oct 2020 03:17:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=KBgUGqAsec7qTzYBCwd44M5Bggj7329Sl4ThqGqVzJM=; b=r/hMWlZ4hVnBC2hqLPzHYZgF1TNMYUt3GXbZTY8LUpvdzb3UeH/58LdOQAF50BrPSu ot3W4Pka1heK0dMFCEVwy+ec+8DwZ0LAstnAzI7O3zL2GamUBZ/wAn3KYPon+XqiL5Iu EHZ2WbzC0V6fTUTVlUuWNkKGEYrzskzNkmNLZiaea57qknUyyJKZo4qkx/VOWGFIrP2m 1kHWq/Nak/x7eFhuTa8hwn01pzhufsMDXpFe9Zeg4ZNH+JLLnbOmJqS1QiK3+6eBJ57o P1IuJuK9EYSUErL6KYAVlayxNb3zQ6VY+dPn3ap6fh9+AplcqqX37WwwwnRhcpAzRLCE VQ0Q== 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=KBgUGqAsec7qTzYBCwd44M5Bggj7329Sl4ThqGqVzJM=; b=oFAZvXNWWuSLZQW0UYofmJE/rqFS1padu7jFzMX88jhDbUDuhp5XTe3mL98Ck4gAID /cQATjAXbY9KGh/imuwr0kRebIewf1GaHbiZlQ4AdqRCkq66rcQwZxZPxVvP6PQ1k3xZ bQSLkL/P/NkhI1BcsYaaJRZ3t5yCwLwa+Wk7Hf5xpXBjz01RMXcbMUMcuj4+fCcVwmqa 04cVDLAhvMTC8/IE8b1sBu8grTBRvzstqYAdiBoYA4MapFXbn0jbKTr0JQCAUAXPROlg eLuw1sFLMXO/DlTQHpUKjltMfw6KOZ2rWsBJDi4mBJzfjAQcHLlfsYWIqae3vng66Xos gFHg== X-Gm-Message-State: AOAM533L9tl3t430VTbQYi4KoTHSe+YQLbdKYLclIPQWk1ejwcFp+SVB vJMiTKG4ddttA89f4tffNUWxLQ== X-Google-Smtp-Source: ABdhPJzpaqsa0RbT5sEashXu9M6QUhoszt2eaPXIsUdeL0oyZG+MPVMN8ttZ0H+dYoeNEhvnCMgYSg== X-Received: by 2002:aa7:9e9d:0:b029:152:5ebd:42a with SMTP id p29-20020aa79e9d0000b02901525ebd042amr16038190pfq.4.1603102649670; Mon, 19 Oct 2020 03:17:29 -0700 (PDT) Received: from Smcdef-MBP.local.net ([103.136.220.99]) by smtp.gmail.com with ESMTPSA id g85sm11427520pfb.4.2020.10.19.03.17.25 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Oct 2020 03:17:29 -0700 (PDT) From: Muchun Song To: akpm@linux-foundation.org, sfr@canb.auug.org.au, osalvador@suse.de, alexander.h.duyck@linux.intel.com, mhocko@suse.com, yang.shi@linux.alibaba.com, david@redhat.com, hannes@cmpxchg.org, hughd@google.com Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Muchun Song Subject: [PATCH] mm/memory.c: Introduce non-atomic __{Set,Clear}PageSwapCache Date: Mon, 19 Oct 2020 18:15:20 +0800 Message-Id: <20201019101520.12283-1-songmuchun@bytedance.com> X-Mailer: git-send-email 2.21.0 (Apple Git-122) MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000001, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: For the exclusive reference page, the non-atomic operations is enough, so replace them to non-atomic operations. Signed-off-by: Muchun Song Acked-by: Michal Hocko Acked-by: Yanfei Xu --- include/linux/page-flags.h | 2 ++ mm/memory.c | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h index fbbb841a9346..ec039dde5e4b 100644 --- a/include/linux/page-flags.h +++ b/include/linux/page-flags.h @@ -401,6 +401,8 @@ static __always_inline int PageSwapCache(struct page *page) } SETPAGEFLAG(SwapCache, swapcache, PF_NO_TAIL) CLEARPAGEFLAG(SwapCache, swapcache, PF_NO_TAIL) +__SETPAGEFLAG(SwapCache, swapcache, PF_NO_TAIL) +__CLEARPAGEFLAG(SwapCache, swapcache, PF_NO_TAIL) #else PAGEFLAG_FALSE(SwapCache) #endif diff --git a/mm/memory.c b/mm/memory.c index 2d267ef6621a..02dd62da26e0 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -3128,10 +3128,10 @@ vm_fault_t do_swap_page(struct vm_fault *vmf) set_page_private(page, entry.val); /* Tell memcg to use swap ownership records */ - SetPageSwapCache(page); + __SetPageSwapCache(page); err = mem_cgroup_charge(page, vma->vm_mm, GFP_KERNEL); - ClearPageSwapCache(page); + __ClearPageSwapCache(page); if (err) { ret = VM_FAULT_OOM; goto out_page;