Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp146376ybh; Tue, 17 Mar 2020 20:03:11 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuLc3/1gsMznESRh6O6RMB9BD1aRqu5XrtNI6CMIwDaMwURTbdmLDOw4ZnVVGZhCg4wMWc7 X-Received: by 2002:aca:d985:: with SMTP id q127mr1532717oig.132.1584500590661; Tue, 17 Mar 2020 20:03:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584500590; cv=none; d=google.com; s=arc-20160816; b=n3/uqYrzwFQQA2Qno1sEeX66qdl0ILC9eGILI4Pk/A3w8+wiJ6BmkuZoiWF228wDvS fjUqGEAvrT/9/nXk5a1wSKIp81nWVrwVSqOuHtr5ycw4ndtcz0hVRi6qxOPi2eoccsXS bewHwvLAHIiaSh3FLBJdLjswJlFvuQ/KN6MoB+oh5c8aw8/GOEa4K8Dc2SkJS0jibgFR mcjllh96sr7ZLIih7uKbxta2yGzgEPB0zBj0+iuORgWH1xJOFHgK3CNgWx4+f9GegzUG rIvYgeu1S7SAktMJJyEtT6E8CxAYflMH1aNcDp+LdCwX+YEh1YyVAoMBZ4tEul7FLiAh zVMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=/Cos+xgkC8QkW3pkmh8LZqTIWz653gA5P8bRVFeBYpA=; b=FEzp6f8z6mQtDpuSI+iaaIsO+rHLWM/yPqA4Ktx0TDV0xfhdRVluKMpDvt64tA7fuJ tYhG5hD6hV3O4rs4sovoAaVpiOZvoHEsv0F6T2UDgAjHZqYrK/sAHwc+0Y/9PaKP6lvR 3mH9Lx1m9bOi46hl9eT65J9o1lJcC2CMIEoWpwh+/TMvjAlzdxKLT17OVt1EqDrT+01S mmtCVtCG7SpqEaolbCwl6p33Yn5LskE4QQn2CQLApowSlmKUh6pLXf9V3JYrrTctaE5B 7koyhzxjEJ0asq9V7UETTCbcm2x0Yf1aoGtS0/h+KIm/d1K4+rDyn5mSQ0FrZlAeeVDC wYpQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g23si2570967otk.248.2020.03.17.20.02.57; Tue, 17 Mar 2020 20:03:10 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726646AbgCRDCk (ORCPT + 99 others); Tue, 17 Mar 2020 23:02:40 -0400 Received: from out30-42.freemail.mail.aliyun.com ([115.124.30.42]:58456 "EHLO out30-42.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726229AbgCRDCk (ORCPT ); Tue, 17 Mar 2020 23:02:40 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R131e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e07417;MF=yang.shi@linux.alibaba.com;NM=1;PH=DS;RN=7;SR=0;TI=SMTPD_---0TsvBh-R_1584500549; Received: from localhost(mailfrom:yang.shi@linux.alibaba.com fp:SMTPD_---0TsvBh-R_1584500549) by smtp.aliyun-inc.com(127.0.0.1); Wed, 18 Mar 2020 11:02:37 +0800 From: Yang Shi To: shakeelb@google.com, vbabka@suse.cz, willy@infradead.org, akpm@linux-foundation.org Cc: yang.shi@linux.alibaba.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [v4 PATCH 2/2] mm: swap: use smp_mb__after_atomic() to order LRU bit set Date: Wed, 18 Mar 2020 11:02:21 +0800 Message-Id: <1584500541-46817-2-git-send-email-yang.shi@linux.alibaba.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1584500541-46817-1-git-send-email-yang.shi@linux.alibaba.com> References: <1584500541-46817-1-git-send-email-yang.shi@linux.alibaba.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Memory barrier is needed after setting LRU bit, but smp_mb() is too strong. Some architectures, i.e. x86, imply memory barrier with atomic operations, so replacing it with smp_mb__after_atomic() sounds better, which is nop on strong ordered machines, and full memory barriers on others. With this change the vm-scalability cases would perform better on x86, I saw total 6% improvement with this patch and previous inline fix. The test data (lru-file-readtwice throughput) against v5.6-rc4: mainline w/ inline fix w/ both (adding this) 150MB 154MB 159MB Fixes: 9c4e6b1a7027 ("mm, mlock, vmscan: no more skipping pagevecs") Acked-by: Vlastimil Babka Reviewed-and-Tested-by: Shakeel Butt Signed-off-by: Yang Shi --- v3: * Added Shakeel's review-and-test signature. v2: * Solved the comment from Vlastimil and added his Ack. mm/swap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/swap.c b/mm/swap.c index cf39d24..74ea08a 100644 --- a/mm/swap.c +++ b/mm/swap.c @@ -931,7 +931,6 @@ static void __pagevec_lru_add_fn(struct page *page, struct lruvec *lruvec, VM_BUG_ON_PAGE(PageLRU(page), page); - SetPageLRU(page); /* * Page becomes evictable in two ways: * 1) Within LRU lock [munlock_vma_page() and __munlock_pagevec()]. @@ -958,7 +957,8 @@ static void __pagevec_lru_add_fn(struct page *page, struct lruvec *lruvec, * looking at the same page) and the evictable page will be stranded * in an unevictable LRU. */ - smp_mb(); + SetPageLRU(page); + smp_mb__after_atomic(); if (page_evictable(page)) { lru = page_lru(page); -- 1.8.3.1