Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp4022195ybh; Tue, 17 Mar 2020 10:44:25 -0700 (PDT) X-Google-Smtp-Source: ADFU+vsjYQjoJlJMYy74fvkzhKQUbuK9f9IM1OFW6Kru8kZ9fDoBmQ3sYd3VWWdpl9yC7kV7rmJ/ X-Received: by 2002:aca:b9c2:: with SMTP id j185mr24339oif.112.1584467065680; Tue, 17 Mar 2020 10:44:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584467065; cv=none; d=google.com; s=arc-20160816; b=z0t8ISueIE32t3gONAzAstpNa7vuEyJj8FJw9rMHMn/efEfKpJPK8hcfzPDucBN/TK EEsWFcEG4xhPtgIdb0QiVeE4h4JrbubIMCiqL7pYzjFIxp1OfbCi3CoQALX8zGclrXc3 2DG4C/KV3wYyu8Sx2m0s/civQSC00fXpc5vOD7P/zNd3Z5xncC2f8Vy4rlQeAMCQBEq3 Xihb4umxa2CiUQJoFS6atiGP8Qey7ORetWNr19QvjaMpz9urQk8tyI/MD9X0ZKPX8zfy QoIsQ0gTst66NWukVOD0lXyR9gdWYRsdApJR9fHkRGvIk/F9/RExz5m9pnzINNVscpqC 15pg== 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=va9LlxAGq4hNaEKxcRG96W2Sg99COtqdvTnpMNxrOME=; b=TKow2huO9dcbUH4p9wNZrAp0SufJzDwqkUJbUzw/aZ0lcn6orcGE8yXstlg7HgMQwO eKQEEguA3C/26+eJ3/V+9SZfmbgYWM4VGHvjjP0LWIf4TYNQmJXRsXUNIeG/xIasmuTI hkPX7N4Uf+POulKQE+1ECAoqnN42rF0EhARWHx7B9lMWjrRvMcRaMyM/gaPocC6xF2+T U5Blt8GxTf2EvU14bN2QzjsADQIByUgTMNkG68ugWMQW3j+pVoXnSV84l4jb53tdc5Al 4gB9B1NHn52YyJzk/CnORUu3AYFgPn1mlpULuIIaPJZ9xekpzicj8oGlTkyGB0wXEXHK HLzg== 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 p6si1927317oth.259.2020.03.17.10.44.13; Tue, 17 Mar 2020 10:44:25 -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 S1726740AbgCQRnQ (ORCPT + 99 others); Tue, 17 Mar 2020 13:43:16 -0400 Received: from out30-54.freemail.mail.aliyun.com ([115.124.30.54]:59924 "EHLO out30-54.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726491AbgCQRnQ (ORCPT ); Tue, 17 Mar 2020 13:43:16 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R111e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01f04446;MF=yang.shi@linux.alibaba.com;NM=1;PH=DS;RN=7;SR=0;TI=SMTPD_---0Tstzj4p_1584466980; Received: from localhost(mailfrom:yang.shi@linux.alibaba.com fp:SMTPD_---0Tstzj4p_1584466980) by smtp.aliyun-inc.com(127.0.0.1); Wed, 18 Mar 2020 01:43:07 +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: [v3 PATCH 2/2] mm: swap: use smp_mb__after_atomic() to order LRU bit set Date: Wed, 18 Mar 2020 01:42:51 +0800 Message-Id: <1584466971-110029-2-git-send-email-yang.shi@linux.alibaba.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1584466971-110029-1-git-send-email-yang.shi@linux.alibaba.com> References: <1584466971-110029-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-calability 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