From patchwork Mon Jan 3 01:35:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 12702409 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 96B9CC433F5 for ; Mon, 3 Jan 2022 01:35:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 28E0A6B0071; Sun, 2 Jan 2022 20:35:54 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 23D5B6B0073; Sun, 2 Jan 2022 20:35:54 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 105FE6B0074; Sun, 2 Jan 2022 20:35:54 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0052.hostedemail.com [216.40.44.52]) by kanga.kvack.org (Postfix) with ESMTP id 016756B0071 for ; Sun, 2 Jan 2022 20:35:53 -0500 (EST) Received: from smtpin10.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id BBAE58F6D3 for ; Mon, 3 Jan 2022 01:35:53 +0000 (UTC) X-FDA: 78987259386.10.7CF2AB0 Received: from mail-qk1-f172.google.com (mail-qk1-f172.google.com [209.85.222.172]) by imf24.hostedemail.com (Postfix) with ESMTP id BE458180003 for ; Mon, 3 Jan 2022 01:35:45 +0000 (UTC) Received: by mail-qk1-f172.google.com with SMTP id m2so28348085qkd.8 for ; Sun, 02 Jan 2022 17:35:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:from:to:cc:subject:message-id:mime-version; bh=JaSZZ+/ZBLkNzEcEn9eD+IlDGjCZFtM4r21Mxyksolg=; b=hT+6aP4/NC3vMVqIhmCXqGkMBlMD5MdP9vNNwMtApmbOflavOSVhqzfKbVOsBAZBq7 9tTaDUAhg829po65kAvLTn9iMygiB2/kWOd1VwWe8ipImHI7uJEixSZM5Fr5/CrJoH0F bjUo7d8TaCIGijcO4F0SN7kj54IKT027e82lDAcjzwldGVVsaS14B3i5SpoDgq6gqFw+ 1xoCmt26e37Ywc9tWAMH46RJiqDda3iJE9tm3YBtr9/+WDO5Yy6DT1/wUZ7CIt93Q5ks 4HJHfNKAotvDbnIoP7CKCyjZ9KOn/XgvebnatVwfHtf7oXaOuAxBHweJCIZ10UOVpVg/ sIpQ== 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:message-id:mime-version; bh=JaSZZ+/ZBLkNzEcEn9eD+IlDGjCZFtM4r21Mxyksolg=; b=pemzlNx/OFcr3YRyofTPM7yUGRoCOkAbv9BytXxwieMs2UBVuz3DYHeGj959YBQ3RX jH2BXvzxM9e+wiNHV/qfqUlWy8efk6otOwK8RpVo4VLfa8blNP6XT4QVtHkxWYc26BTE IzmVmUyAOUFYD+nLe0Hv68hUw+GZ9DzJWSKKkKti9kw3sG++aDYHgAbX78Ah3nxODGYh JcRXdppTHdobgan2bc7nMnMvxjYk32+xSbSd8a678W+Nfo1PFppSKuMoP/L9nSseg2da CeA7TXisXlTI+4Bwqe7j/76nP3L48mvZCYGfDq3G0MsWdbhRsPljUMcaht1PQd8B3blK 7fGg== X-Gm-Message-State: AOAM5310YjT0SY8y8n6EuNAB3qiJxfsS4sXjF7qWcAbvp9yHTchdugbZ fm82XkZq8/jgBdF5NSFGl2gLfw== X-Google-Smtp-Source: ABdhPJzoXsD5f7PvFJQ6Mu9VEZlpODAEzB2rbY5NHjHbnv/vRbwrq0S3GSu4FEPFxBMNh3OBJOHiAQ== X-Received: by 2002:a05:620a:c4f:: with SMTP id u15mr31341532qki.565.1641173752550; Sun, 02 Jan 2022 17:35:52 -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 r20sm27971780qkp.21.2022.01.02.17.35.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 02 Jan 2022 17:35:52 -0800 (PST) Date: Sun, 2 Jan 2022 17:35:50 -0800 (PST) From: Hugh Dickins X-X-Sender: hugh@ripple.anvils To: Matthew Wilcox cc: Andrew Morton , Christoph Hellwig , Jan Kara , William Kucharski , linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH next 3/3] shmem: Fix "Unused swap" messages Message-ID: <49ae72d6-f5f-5cd-e480-e2212cb7af97@google.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: BE458180003 X-Stat-Signature: om5ikqr7bwrkor1d8ob35t8sz7yysxuy Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b="hT+6aP4/"; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf24.hostedemail.com: domain of hughd@google.com designates 209.85.222.172 as permitted sender) smtp.mailfrom=hughd@google.com X-Rspamd-Server: rspam02 X-HE-Tag: 1641173745-437393 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: 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. Fixes: 3103f9a51dd0 ("mm: Use multi-index entries in the page cache") Signed-off-by: Hugh Dickins --- mm/shmem.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) --- hughd2/mm/shmem.c +++ hughd3/mm/shmem.c @@ -727,9 +727,8 @@ static int shmem_add_to_page_cache(struc do { void *entry; xas_lock_irq(&xas); - while ((entry = xas_find_conflict(&xas)) != NULL) { - if (entry == expected) - continue; + entry = xas_find_conflict(&xas); + if (entry != expected) { xas_set_err(&xas, -EEXIST); goto unlock; }