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 3FFC4C433F5 for ; Sun, 6 Feb 2022 21:45:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9BAFE6B0072; Sun, 6 Feb 2022 16:45:55 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 969156B0073; Sun, 6 Feb 2022 16:45:55 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 80A5D6B0074; Sun, 6 Feb 2022 16:45:55 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0171.hostedemail.com [216.40.44.171]) by kanga.kvack.org (Postfix) with ESMTP id 6E3056B0072 for ; Sun, 6 Feb 2022 16:45:55 -0500 (EST) Received: from smtpin15.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 29FBF181DA55E for ; Sun, 6 Feb 2022 21:45:55 +0000 (UTC) X-FDA: 79113687870.15.91ED692 Received: from mail-oo1-f42.google.com (mail-oo1-f42.google.com [209.85.161.42]) by imf26.hostedemail.com (Postfix) with ESMTP id B4594140002 for ; Sun, 6 Feb 2022 21:45:54 +0000 (UTC) Received: by mail-oo1-f42.google.com with SMTP id w5-20020a4a9785000000b0030956914befso11654284ooi.9 for ; Sun, 06 Feb 2022 13:45:54 -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=AZqi60Yr8HuyENh7V3NHOA86mYT9XQfDwkJWeap6Hv4=; b=EgwdjpiSVtHtN8gYa4GpexZ70qbUL2NhrWgKXCXX2LBjGnHl6TuVJ82lRvT9pl11bg GJZIbQQd9vEHvf9Zaur5QaXjfBcZlU0agDbAgqx6EwcJhU9ycAqDSyi/QUJ4XFJ9K08N OTfMUECr1/9GvCfG3nvoih7TFdihwBIYkxfomgc/AvmEnFFzxUAaoRPOqI1otAkhH5Vh DFi2Jxxxg0xETEmbuQ7CygU4Gh9Xkuh1ncDOi+CmXMyWjIvMfQfyvE3qLgldgW/7DMeW zorJdpcn6kqIrFJ70Po9q2a1vrjeggAUpPytS5SWHMYC5ktbrUb60kJ9zlyBYyveZZjp uDEg== 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=AZqi60Yr8HuyENh7V3NHOA86mYT9XQfDwkJWeap6Hv4=; b=PYLo/Ki3sIIu8mdSBXwLS/Vt49bXnAjKBHewjQRUVeyjQHDPojeE3glqza0wwc4Y+R Kowo2JcbBb6D9oXRLV7sPtyUn8Ndko1OPQEnbAdGjDGvgRSWxuDTEjPzGBPH3UNtmGH9 iDJ+6Ve5wg+TbLcEHfv04xMs9rcx04o84OYxj0UhUPxas6EFIebposXTFGEZZbGcDBUX a8cg48ljMPrrwbtu7QsEqbBq0dFOD77PmVW/m+ATfIjV2FVpMHDPUzHv54YHxyx7pexi cfPdNXwZPITu5vnV5DKlyNSBDoq+zRXapL4znPvgT08oDdbCNwuSd4SGOJmHUJ5hekhs XTYw== X-Gm-Message-State: AOAM531dyAyVU/KwonEZVG3+zWVD8CtvlICVOmDOSEtCwX1rMR+CDUmk 6FmIOChD7bp3mdwlwmV6QbFQSw== X-Google-Smtp-Source: ABdhPJwuhT+ew2mJdr3D6cKZkrBLmmLSOMdPtFq393BKGZKWDkUv4JaIpVMPIZUPwS+O+DyMnFtz2g== X-Received: by 2002:a4a:b2ca:: with SMTP id l10mr2861159ooo.13.1644183953803; Sun, 06 Feb 2022 13:45:53 -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 n24sm3442036oao.40.2022.02.06.13.45.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 06 Feb 2022 13:45:53 -0800 (PST) Date: Sun, 6 Feb 2022 13:45:50 -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 09/13] mm/munlock: delete smp_mb() from __pagevec_lru_add_fn() In-Reply-To: <8e4356d-9622-a7f0-b2c-f116b5f2efea@google.com> Message-ID: <9121d34d-4889-51f1-56c7-255138f43b8d@google.com> References: <8e4356d-9622-a7f0-b2c-f116b5f2efea@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Rspam-User: nil X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: B4594140002 X-Stat-Signature: bmdwcfh4eafugngmyozokpi7khr9ekoi Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=EgwdjpiS; spf=pass (imf26.hostedemail.com: domain of hughd@google.com designates 209.85.161.42 as permitted sender) smtp.mailfrom=hughd@google.com; dmarc=pass (policy=reject) header.from=google.com X-HE-Tag: 1644183954-760272 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 --- 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