Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp2026229ybh; Fri, 13 Mar 2020 11:36:13 -0700 (PDT) X-Google-Smtp-Source: ADFU+vtxr9C7PPoDWKGIsX5NFAPOdgI/wkr9LKlTv7rBrJ7n8zwjmrs7/l74f372F2v1AnCaxsVC X-Received: by 2002:aca:af93:: with SMTP id y141mr7840200oie.144.1584124573387; Fri, 13 Mar 2020 11:36:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584124573; cv=none; d=google.com; s=arc-20160816; b=UmGkbHCsNGp1Eh7F2kXDqbfimFzzqx/Xvo+99XnLQ122PraTOUv8YULtKsIV/qgIkX UcZ+PZlPRIiyUKClvM8TPfXNF6g4wS0X+vnXrnF9ZHW4wpbrG6BUPr9wGTo3iKxapJ43 9cfGLMVLFWnq5C6PsbLF1ZWwNF+FAuNSN4WumurWFQ2oLDIZ0DQce9Pp7VHB2kISsUJr PV6/+ECgnlDS8L9EOJwz9CsvGt/B9GdismuMvXq9FslmSI1dgJEo84hX1fKxAljr+NNK aDTTt/g3ZajslwCWU5qpe68ky9sDLb+j4jeUxDmWX8pbgC9Usy4Z897ML/6oGN5yEQqi CUWw== 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=DqMKJcarMBkFmVGK/tXBLKoN7Lf+oyE3zZl42k+hF0w=; b=m040Lh0u4Yl3+P0GXuZJ+qvuyBE4FWCT3i1adkWPepEadNlei5VZvLQGZISVithWzP podsJdCc+/qInx9DL+QbEd5eRcN1Y24ZBj9x0ssFoDEQJcZAGq4Q9RyZYMs/80KjnFLc t2kHbUSo8ICD3CypoLOZb+PTHYoxafkSIUCyQkmoTcWiGZyefmAIoq12qH1Sj/8vtYlP G+eUtjZTMsxajptHx6d622OhXdCRv9c3CwfZA0wUTAY91NgWwGLvME62I/sSFQ2SrmAv Zgu44+2EOi2Oq4rzGbUj99/xfVCxnpH2SacQYazArmi4fWvSDS88GoqGCWPCWfD8kRbB 6hGg== 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 c19si1568310ots.118.2020.03.13.11.36.00; Fri, 13 Mar 2020 11:36: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 S1727481AbgCMSfG (ORCPT + 99 others); Fri, 13 Mar 2020 14:35:06 -0400 Received: from out30-43.freemail.mail.aliyun.com ([115.124.30.43]:50132 "EHLO out30-43.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727279AbgCMSfB (ORCPT ); Fri, 13 Mar 2020 14:35:01 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R151e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01f04397;MF=yang.shi@linux.alibaba.com;NM=1;PH=DS;RN=6;SR=0;TI=SMTPD_---0TsUkHy3_1584124485; Received: from localhost(mailfrom:yang.shi@linux.alibaba.com fp:SMTPD_---0TsUkHy3_1584124485) by smtp.aliyun-inc.com(127.0.0.1); Sat, 14 Mar 2020 02:34:53 +0800 From: Yang Shi To: shakeelb@google.com, vbabka@suse.cz, akpm@linux-foundation.org Cc: yang.shi@linux.alibaba.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] mm: swap: use smp_mb__after_atomic() to order LRU bit set Date: Sat, 14 Mar 2020 02:34:36 +0800 Message-Id: <1584124476-76534-2-git-send-email-yang.shi@linux.alibaba.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1584124476-76534-1-git-send-email-yang.shi@linux.alibaba.com> References: <1584124476-76534-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 Cc: Vlastimil Babka Signed-off-by: Yang Shi --- mm/swap.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mm/swap.c b/mm/swap.c index cf39d24..118bac4 100644 --- a/mm/swap.c +++ b/mm/swap.c @@ -945,20 +945,20 @@ static void __pagevec_lru_add_fn(struct page *page, struct lruvec *lruvec, * #0: __pagevec_lru_add_fn #1: clear_page_mlock * * SetPageLRU() TestClearPageMlocked() - * smp_mb() // explicit ordering // above provides strict + * MB() // explicit ordering // above provides strict * // ordering * PageMlocked() PageLRU() * * * if '#1' does not observe setting of PG_lru by '#0' and fails * isolation, the explicit barrier will make sure that page_evictable - * check will put the page in correct LRU. Without smp_mb(), SetPageLRU + * check will put the page in correct LRU. Without MB(), SetPageLRU * can be reordered after PageMlocked check and can make '#1' to fail * the isolation of the page whose Mlocked bit is cleared (#0 is also * looking at the same page) and the evictable page will be stranded * in an unevictable LRU. */ - smp_mb(); + smp_mb__after_atomic(); if (page_evictable(page)) { lru = page_lru(page); -- 1.8.3.1