Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp3076756ybh; Mon, 16 Mar 2020 15:25:14 -0700 (PDT) X-Google-Smtp-Source: ADFU+vtfiOC75vfsxEtKOC5vrnAMZW0OyfI9ORi/sDSjAcH2GAG/tbBMXWsF04CeyhuhPhQ80lWU X-Received: by 2002:aca:b5c3:: with SMTP id e186mr1274462oif.114.1584397513845; Mon, 16 Mar 2020 15:25:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584397513; cv=none; d=google.com; s=arc-20160816; b=eteWIJ0NyQDBDI0k2oLxkUR1b2WoaeHNmSor3UfNXtVyWIHNX/cbLC43mFROcBn/ll a0tI8k8p7ZLQiACUJAaH7giwP1bSbDF4UpD20ciuhPBwgiSMRBYpZRPkxqcMIJWUBU7j btFgXpd36rfRXlWZe08KjwNyvm9Ytg9QAaRGE+pjiFokV8JMOWMXuzJ7VrbrYSiWjMrP yDWrbk9h2nqunIukavPG4vt/IyI8iEImXP2zD1p3zpV/Ztze8soeouhLYPk+VWOcYuET J8Dcb9Vm300fPdCj20pYaJJOW8SFT4Z0fxYlkiRX/blMfpZe8vKaMNbdH7e+5m8Y/2xW 0mjQ== 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=HVlzHjxdR0vCSplwZPsyOPwKZeUFBLg1lyPiiPl/+LE=; b=zVo8/hTD9eN1ihb5M3qNxtnSD9A2EHv1yI4rkGpOxPj5uS2hDt+ZP7kdoN/gCaCdqu BY0ZP+cSwusiIHkgDfH07z1txphEqWD9Q+wrOFxFRYD45QN/CbL5oBrJddqfdAVurK8o OT8O+hnDYxJtYddW0l6EHrPEhEayhzKB2vWH+FAPKXHQiQvyEqTGcFryDPIO+cWKg9Mp UgV9mDDNLPGB6Ok66d7GGyiR43lVsP+DiREglaLyEltZLxmIMcfinBp3FGMdmU3puCbQ IDj+zoJLfwVqsW7a44UPcuC3VZYhM90LjCMzMtzpJYTYloeiLb/MTPOPWV4OfM4ew1CC N2Vg== 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 i124si684307oib.172.2020.03.16.15.24.55; Mon, 16 Mar 2020 15:25:13 -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 S1732791AbgCPWYd (ORCPT + 99 others); Mon, 16 Mar 2020 18:24:33 -0400 Received: from out30-54.freemail.mail.aliyun.com ([115.124.30.54]:46530 "EHLO out30-54.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732779AbgCPWYc (ORCPT ); Mon, 16 Mar 2020 18:24:32 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R101e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01f04391;MF=yang.shi@linux.alibaba.com;NM=1;PH=DS;RN=7;SR=0;TI=SMTPD_---0TsosYm0_1584397463; Received: from localhost(mailfrom:yang.shi@linux.alibaba.com fp:SMTPD_---0TsosYm0_1584397463) by smtp.aliyun-inc.com(127.0.0.1); Tue, 17 Mar 2020 06:24:30 +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: [v2 PATCH 2/2] mm: swap: use smp_mb__after_atomic() to order LRU bit set Date: Tue, 17 Mar 2020 06:24:15 +0800 Message-Id: <1584397455-28701-2-git-send-email-yang.shi@linux.alibaba.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1584397455-28701-1-git-send-email-yang.shi@linux.alibaba.com> References: <1584397455-28701-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") Cc: Shakeel Butt Acked-by: Vlastimil Babka Signed-off-by: Yang Shi --- 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