From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1E510C433F5 for ; Tue, 15 Feb 2022 02:34:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AF3A76B0078; Mon, 14 Feb 2022 21:34:51 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id AA1536B007B; Mon, 14 Feb 2022 21:34:51 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 969046B007D; Mon, 14 Feb 2022 21:34:51 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0178.hostedemail.com [216.40.44.178]) by kanga.kvack.org (Postfix) with ESMTP id 897FC6B0078 for ; Mon, 14 Feb 2022 21:34:51 -0500 (EST) Received: from smtpin29.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 4281A181AC9C6 for ; Tue, 15 Feb 2022 02:34:51 +0000 (UTC) X-FDA: 79143446382.29.339ADBA Received: from mail-qk1-f180.google.com (mail-qk1-f180.google.com [209.85.222.180]) by imf11.hostedemail.com (Postfix) with ESMTP id B6C9740006 for ; Tue, 15 Feb 2022 02:34:50 +0000 (UTC) Received: by mail-qk1-f180.google.com with SMTP id c189so16115416qkg.11 for ; Mon, 14 Feb 2022 18:34:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:from:to:cc:subject:in-reply-to:message-id:references :mime-version; bh=klh+DPqWZ+BlnUaC467qqykgES+6efAa+duJH3TYeKQ=; b=jBkp8ISwEWhgcDAzMbPhNGwAR1nASKVb7CoYeFtaLEF/od82lqGj5kJWJxxx3EfYvw HARVTVmf4PvZvD5gbkHVJGZL8Qpt7sIYLwOOI0ntN217CcbSoJjuWfBJwDPhMb66JRm+ j5bsT6aT3EgKAVckTOcYnP3SwkxTysD8FDjEYT6RFLZSY9XIuDUZjtHMHplFrNP2sq7W 74tuE87UchsdHKKjwsUvDOrSl3RyQRAchqim6HJRns8K/SSS8gn7WeTPMvEJk7UCSxl5 5yP8gG5lcuD1rwU1oZ0TOUdrlpwFG874LE/tYnD9s+RijMGeRxZ4XsycvemP6XdVIg74 LrZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:in-reply-to:message-id :references:mime-version; bh=klh+DPqWZ+BlnUaC467qqykgES+6efAa+duJH3TYeKQ=; b=EB+SizVyFXCtl9a4+doWrT2mbO6hhVQ8LqHnII9mjm4bY+OsKN0MaJFNE09mJBk/3B qY+4EeL2hqqgNu4yP/r50qsWTyhLCk/eGmIDhKEbdfliiDCil9cyk1Tqw5E/2XDACeGf MlZR1I1IQp+bQA0VUfuLkzIOHaRfarkCQgS+zqrGtWafCAz7cZvDv4VyzOQHYboEt0jZ f/tW6RnfZICLM/AdKc98KNwJUqDzVMq7N15kGamI6qwbku12diq/Cl0WI2BUoUMrzaQJ wP0FDJo075BJP+Uy9QwzmZ+aIRw2IVnxqQdVffZDShV9kqWZpe3wUbldSmbt3RC7WHq7 Rvfg== X-Gm-Message-State: AOAM530ehXCS7qAD5YrT4jY5MsVhKOJlvkrW8VsiXz8qi/3lSGKs6h7P LxZcHi9UPkqCHH14wI7Cd1PrdsYoHWJVeA== X-Google-Smtp-Source: ABdhPJzGX7gP6ZEL5R3ZPtyweqq4fZ2IbQmSK/ERVYTD1l3o8HEmWHpmokabNmD4RrCsoVQTrR9s4g== X-Received: by 2002:a37:f902:: with SMTP id l2mr1013027qkj.392.1644892489924; Mon, 14 Feb 2022 18:34:49 -0800 (PST) Received: from ripple.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id bk23sm16516786qkb.3.2022.02.14.18.34.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Feb 2022 18:34:49 -0800 (PST) Date: Mon, 14 Feb 2022 18:34:46 -0800 (PST) From: Hugh Dickins X-X-Sender: hugh@ripple.anvils To: Andrew Morton cc: Michal Hocko , Vlastimil Babka , "Kirill A. Shutemov" , Matthew Wilcox , David Hildenbrand , Alistair Popple , Johannes Weiner , Rik van Riel , Suren Baghdasaryan , Yu Zhao , Greg Thelen , Shakeel Butt , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v2 09/13] mm/munlock: delete smp_mb() from __pagevec_lru_add_fn() In-Reply-To: <55a49083-37f9-3766-1de9-9feea7428ac@google.com> Message-ID: <28a7c6ff-6270-9060-8df0-862bdcaac366@google.com> References: <55a49083-37f9-3766-1de9-9feea7428ac@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=jBkp8ISw; spf=pass (imf11.hostedemail.com: domain of hughd@google.com designates 209.85.222.180 as permitted sender) smtp.mailfrom=hughd@google.com; dmarc=pass (policy=reject) header.from=google.com X-Rspamd-Server: rspam07 X-Rspam-User: X-Rspamd-Queue-Id: B6C9740006 X-Stat-Signature: h8m8s63bdu3p6apd537opsiio159prxg X-HE-Tag: 1644892490-23758 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: My reading of comment on smp_mb__after_atomic() in __pagevec_lru_add_fn() says that it can now be deleted; and that remains so when the next patch is added. Signed-off-by: Hugh Dickins Acked-by: Vlastimil Babka --- v2: same as v1. mm/swap.c | 37 +++++++++---------------------------- 1 file changed, 9 insertions(+), 28 deletions(-) diff --git a/mm/swap.c b/mm/swap.c index 682a03301a2c..3f770b1ea2c1 100644 --- a/mm/swap.c +++ b/mm/swap.c @@ -1025,37 +1025,18 @@ static void __pagevec_lru_add_fn(struct folio *folio, struct lruvec *lruvec) VM_BUG_ON_FOLIO(folio_test_lru(folio), folio); + folio_set_lru(folio); /* - * A folio becomes evictable in two ways: - * 1) Within LRU lock [munlock_vma_page() and __munlock_pagevec()]. - * 2) Before acquiring LRU lock to put the folio on the correct LRU - * and then - * a) do PageLRU check with lock [check_move_unevictable_pages] - * b) do PageLRU check before lock [clear_page_mlock] - * - * (1) & (2a) are ok as LRU lock will serialize them. For (2b), we need - * following strict ordering: - * - * #0: __pagevec_lru_add_fn #1: clear_page_mlock - * - * folio_set_lru() folio_test_clear_mlocked() - * smp_mb() // explicit ordering // above provides strict - * // ordering - * folio_test_mlocked() folio_test_lru() + * Is an smp_mb__after_atomic() still required here, before + * folio_evictable() tests PageMlocked, to rule out the possibility + * of stranding an evictable folio on an unevictable LRU? I think + * not, because munlock_page() only clears PageMlocked while the LRU + * lock is held. * - * - * if '#1' does not observe setting of PG_lru by '#0' and - * fails isolation, the explicit barrier will make sure that - * folio_evictable check will put the folio on the correct - * LRU. Without smp_mb(), folio_set_lru() can be reordered - * after folio_test_mlocked() check and can make '#1' fail the - * isolation of the folio whose mlocked bit is cleared (#0 is - * also looking at the same folio) and the evictable folio will - * be stranded on an unevictable LRU. + * (That is not true of __page_cache_release(), and not necessarily + * true of release_pages(): but those only clear PageMlocked after + * put_page_testzero() has excluded any other users of the page.) */ - folio_set_lru(folio); - smp_mb__after_atomic(); - if (folio_evictable(folio)) { if (was_unevictable) __count_vm_events(UNEVICTABLE_PGRESCUED, nr_pages); -- 2.34.1