Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp6302988rdb; Thu, 14 Dec 2023 14:23:39 -0800 (PST) X-Google-Smtp-Source: AGHT+IHHzXfk4diuuuKgvpPTzpe+s0D9UmAu3hYb9j0cvsCwbAzcpQr1bj+xdWSDJx8ENw9V2FxZ X-Received: by 2002:a05:6808:21a9:b0:3b9:d92a:600a with SMTP id be41-20020a05680821a900b003b9d92a600amr12838314oib.68.1702592619442; Thu, 14 Dec 2023 14:23:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702592619; cv=none; d=google.com; s=arc-20160816; b=k6FXNg9slbAq8oY/5R2Gu7Yl+NUI3/winw6NIlOgxBvP8W60D5IXXyueAdnZUZ2z5a DmaG3Ef3wB0F/p0eLujPSuReoddUUr5AQpz13/d+sGpbTsOe6SCvB/84RBX43zFDQhy+ JPBIaKrqLrIN8OVyDmWe4/JvUZEhzM2BNPyHF5ymhUP2DxSY56ridfhPOmUfo8ZWs8eu zPK2AWljIhTiqTSfgo8y3SS2VlcCxoBklNx8mFgO+iiiwPFNapwyI5Q6CNwFNaI76aWJ RyVkG/EdXb3YTXQXSuphExhLCmdkCkTJeRGp9ehGSlmcOfwImB7u9Cs33rkeoa/HEcsk yKwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=vFzLniE4poG1xOuhvNpS/rQ6d6bPvw3gZvBTt/tKCrw=; fh=n/h2BX51NWmL8C6vqy13qTS2yvSpI74eWubWdxzgbLw=; b=wAiE4UpuSgt+eHvh+zSfhMSrIwEbUhCK6g6C9pHIXmXaIb7mmIlCGyMZ02Ht+BmZ/N U6aoLkxSUxXIHo8j/lZmsoFF9orvasqcUIAoSl5IZgAzQF8GX740+vrIqw5iQoe5IlAO F83L8TJRIZVlgbucl0VgD2DtfJ4aP7mRw1g9buROoxm52V2p6rSveVKJjYdOtYmrIHiJ GJMFQJOCcJKR4Xi73pgMDnmwy4z1IivCqNzS9fRynwriQsRakHcwdllUXXGtMFJyyMTn hjJlGGVl+b2iEwO78DQRXCbu3BccgOnG0piCJv2CT2+OXuqi+HucjvSjQv7wzkxIxuac VGPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=VSnEPKWP; spf=pass (google.com: domain of linux-kernel+bounces-187-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-187-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id a26-20020a0cb35a000000b0067f066b918esi2740892qvf.491.2023.12.14.14.23.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 14:23:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-187-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=VSnEPKWP; spf=pass (google.com: domain of linux-kernel+bounces-187-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-187-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 318581C21DAB for ; Thu, 14 Dec 2023 22:23:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DEBBC3FE27; Thu, 14 Dec 2023 22:23:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="VSnEPKWP" X-Original-To: linux-kernel@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F0A30697AB for ; Thu, 14 Dec 2023 22:23:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 04134C433C7; Thu, 14 Dec 2023 22:23:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1702592601; bh=/iBybz/14xsX0TqeFyiHuR4ZDEOsekfMZngpMh9rS48=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=VSnEPKWPkGYfgsbBCkycraDrTgZUJS3vjZs0plA5/JOOin935OlbvZml8Kf2FF8AG 4Laa4y6xXHx9N+pVIo6AjEUQYhihc6CrCGi22v4o0vJVOu6JHrIeBzt/UPFVoVBuvM MXoFG0AVuuMJP1HO7hFDcAnXT9biAB3IzIabrXCg= Date: Thu, 14 Dec 2023 14:23:20 -0800 From: Andrew Morton To: Yosry Ahmed Cc: Chengming Zhou , Nhat Pham , Chris Li , Johannes Weiner , Seth Jennings , Dan Streetman , Vitaly Wool , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH 5/5] mm/zswap: cleanup zswap_reclaim_entry() Message-Id: <20231214142320.f5cf319e619dbb2127c423e9@linux-foundation.org> In-Reply-To: References: <20231213-zswap-dstmem-v1-0-896763369d04@bytedance.com> <20231213-zswap-dstmem-v1-5-896763369d04@bytedance.com> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On Wed, 13 Dec 2023 17:02:25 -0800 Yosry Ahmed wrote: > On Tue, Dec 12, 2023 at 8:18 PM Chengming Zhou > wrote: > > > > Also after the common decompress part goes to __zswap_load(), we can > > cleanup the zswap_reclaim_entry() a little. > > I think you mean zswap_writeback_entry(), same for the commit title. I updated my copy of the changelog, thanks. > > - /* > > - * If we get here because the page is already in swapcache, a > > - * load may be happening concurrently. It is safe and okay to > > - * not free the entry. It is also okay to return !0. > > - */ > > This comment should be moved above the failure check of > __read_swap_cache_async() above, not completely removed. This? --- a/mm/zswap.c~mm-zswap-cleanup-zswap_reclaim_entry-fix +++ a/mm/zswap.c @@ -1457,8 +1457,14 @@ static int zswap_writeback_entry(struct mpol = get_task_policy(current); page = __read_swap_cache_async(swpentry, GFP_KERNEL, mpol, NO_INTERLEAVE_INDEX, &page_was_allocated, true); - if (!page) + if (!page) { + /* + * If we get here because the page is already in swapcache, a + * load may be happening concurrently. It is safe and okay to + * not free the entry. It is also okay to return !0. + */ return -ENOMEM; + } /* Found an existing page, we raced with load/swapin */ if (!page_was_allocated) {