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 2FF09C433EF for ; Mon, 3 Jan 2022 15:36:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 62F576B0071; Mon, 3 Jan 2022 10:36:53 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5DF716B0073; Mon, 3 Jan 2022 10:36:53 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4CDCE6B0074; Mon, 3 Jan 2022 10:36:53 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0120.hostedemail.com [216.40.44.120]) by kanga.kvack.org (Postfix) with ESMTP id 3DFE76B0071 for ; Mon, 3 Jan 2022 10:36:53 -0500 (EST) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id EDFB08A9A6 for ; Mon, 3 Jan 2022 15:36:52 +0000 (UTC) X-FDA: 78989378664.19.1BA857C Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf27.hostedemail.com (Postfix) with ESMTP id F097A4000B for ; Mon, 3 Jan 2022 15:36:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=7sd73yLtLEQWYazRoKEbo6fL+jWQwJgfDIPjDDhuGTM=; b=WT0cXG6x/4ab5sMR6zMig45pQB rHsLtMoRCUBF7Mk8x1jX6jnEW8fmjFtSBqgjZXIzqr7baE83o4TNFkKW8MhbOZ0pMZj1OQR0URAC+ DcnEzxyJlqrJlV8XpOQSXGY17+vNFjUo80W91gcdwaOtsBN9/Jeu3xcfbUaOMFf7QjjQ0YT9xE43z DuFQGu26CfUmO5tpwBK1dOQLaZXRXSK2tqnR07krueYxCarWR31QvgnJzZ020aIXUAwX7ZO+Yax77 7lObWIcaTni4IBJo58RvnKlPqMWFk1SeCsg1ZGGPZoydPz/1CqemRMdRL7HDtp1BRdbiqWxfZXXHF SaVR+18w==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1n4PO4-00CwFm-Ln; Mon, 03 Jan 2022 15:36:40 +0000 Date: Mon, 3 Jan 2022 15:36:40 +0000 From: Matthew Wilcox To: Hugh Dickins Cc: Andrew Morton , Christoph Hellwig , Jan Kara , William Kucharski , linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH next 3/3] shmem: Fix "Unused swap" messages Message-ID: References: <49ae72d6-f5f-5cd-e480-e2212cb7af97@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <49ae72d6-f5f-5cd-e480-e2212cb7af97@google.com> X-Rspamd-Queue-Id: F097A4000B X-Stat-Signature: 3cjdgnwj1e5j7kehdh7ce9ugbaiajxqp Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=WT0cXG6x; dmarc=none; spf=none (imf27.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org X-Rspamd-Server: rspam11 X-HE-Tag: 1641224210-880725 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: On Sun, Jan 02, 2022 at 05:35:50PM -0800, Hugh Dickins wrote: > shmem_swapin_page()'s swap_free() has occasionally been generating > "_swap_info_get: Unused swap offset entry" messages. Usually that's > no worse than noise; but perhaps it indicates a worse case, when we > might there be freeing swap already reused by others. > > The multi-index xas_find_conflict() loop in shmem_add_to_page_cache() > did not allow for entry found NULL when expected to be non-NULL, so did > not catch that race when the swap has already been freed. > > The loop would not actually catch a realistic conflict which the single > check does not catch, so revert it back to the single check. I think what led to the loop was concern for the xa_state if trying to find a swap entry that's smaller than the size of the folio. So yes, the loop was expected to execute twice, but I didn't consider the case where we were looking for something non-NULL and actually found NULL. So should we actually call xas_find_conflict() twice (if we're looking for something non-NULL), and check that we get @expected, followed by NULL?