Received: by 2002:ab2:b82:0:b0:1f3:401:3cfb with SMTP id 2csp76459lqh; Wed, 27 Mar 2024 15:30:01 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUP4+YU4nRidze+dc9j54cE0L70wIMYzrMRDKZMcBo6p7EaugvoDcrNir7IvGsc6sP04agVPgNIwkSRQpvTj8OADpWTXZSVN2ySfy9+cg== X-Google-Smtp-Source: AGHT+IGAs1cxAgqXfXmqYijMeF6C0PSud2OaU14l/vCWo8N4pa3qQ5rdObRTbxZGc+HgjhLYbPBh X-Received: by 2002:a05:6808:1827:b0:3c3:d477:62d4 with SMTP id bh39-20020a056808182700b003c3d47762d4mr1448230oib.33.1711578601100; Wed, 27 Mar 2024 15:30:01 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711578601; cv=pass; d=google.com; s=arc-20160816; b=JgIoKMnaaVWgmOd4oz+TRoGhmnd+uqpMO+zMQALah9cLD1i+qXZDNixj1p+bGZduwX jqBvu+SRzgjGaTcxQ/BrsVfGXl3HWpCeCuxnKvOZ5fCUea6HHd8lpfXb5gx326vxiArI tB3POSrOmNMc1KiWTc5S2ZgNmSTefBUvOV7yjobyCG518kJFWpJPuvi0Oo7M3EqFKIyp 5nSji3LO56G3zguFPp2miU/xVdG5NG4jUha4c7yF13jHr1GSNolOgYq5nBUdhKdIpuKI hl4MPNCM9SQjwrLdwUpGzC5vqL1yFEAy5In3SaAkLHrJRxDSIQqppChugcWJSmBOFaO8 iNug== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=a7hfzMDD6Cf+PT6Udlfkf6Vck2EoOCaENymKmzHzlvE=; fh=jWP94FG9p7jKpfb1Td7ancTsuXyh9Mmns1QwaPSw+Vc=; b=jz+C8onBxxJNWNhEmituQQqbwFfMrfHJFBRIl1xzdsk8Ymm8yU8mHYLeHjHqklY0wC xmX1uug7wcizmfdRB49Z/420IwJMN1SBOqmf4Elf+By3WNParC7t0XKg1GH4rtTq7ShT 0N/nJHfrmGDhTfruRUP8sA3/JI04A5/7+0bi1TFY6SCqKjt72tjMsdge/DFL4XntbtnD 7j2Bi6jtqiXAv/r41sZ+hPvGirMiN23uR+KIT1bhrOKVtrCuhaSMeaSlqfEUWibB1Buv 3CWTchnxYk9BpkD2nTsGSXryKTIrYNsaDWfadd5iWkcHqhvYF/eoxshNxnfhY8aABRfy V2kA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=uPEWNJrU; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-122100-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-122100-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id y8-20020ac85f48000000b0043143cd3c05si106608qta.414.2024.03.27.15.30.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 15:30:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-122100-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=@google.com header.s=20230601 header.b=uPEWNJrU; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-122100-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-122100-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com 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 C06BD1C31990 for ; Wed, 27 Mar 2024 22:30:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5A3521534F6; Wed, 27 Mar 2024 22:29:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="uPEWNJrU" Received: from mail-ej1-f49.google.com (mail-ej1-f49.google.com [209.85.218.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E27AEEAE5 for ; Wed, 27 Mar 2024 22:29:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711578595; cv=none; b=X9Bx5JpJ2oPez2oNrHyZEN7e/oRZ/QBdZawMfPqUsJoQoOItA6q7AzlH0Rg6OChrmf4eSDlw35HM1R0300Bu6BUT/P+WLOvJ3oNuiJHY08I9uNh1RBlFvKRktu6E2Dc7tqB7Vd8ZOEo2C5bIcvpj6FArCv1HhvHZ6/2C8mNt/tc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711578595; c=relaxed/simple; bh=uQZWf1z2g5EkDsuZ+JXF0zg9NReUumhN41xOtlzzRiQ=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=P2H1LvPKpqVW1J0z1gwQrtwiBxfrFCdOr6HtxSqpp95avXyoHGy5Zw8iYVrC6EW4tGCTAyuly8Oa5M6aBBXjSUZa3Q10bBlDE7gO4Vq1+AVGWnXHq1Y+dBrTLnDhE6d37cUjLI8dkrh9X2FeE+DFnsNpGNJtKVO2O2qPWu5N4V0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=uPEWNJrU; arc=none smtp.client-ip=209.85.218.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-ej1-f49.google.com with SMTP id a640c23a62f3a-a4715d4c2cbso38754166b.1 for ; Wed, 27 Mar 2024 15:29:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1711578592; x=1712183392; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=a7hfzMDD6Cf+PT6Udlfkf6Vck2EoOCaENymKmzHzlvE=; b=uPEWNJrUxtgOOBSOTfSbmkHUy347dgXIRGaH0s5lH3fPyqihKMLSqH9BbDRqIbxkdJ 0feRw9Xi9P+b2wxofsaPmiDPFcLSanSK962lBhnCqFskYZfWicRbG7TQioGSc0zl/snx OoCfUgXMQBx/hRmZDd4PV4bSdr2fohzcYoEEFyULQqGD98t5/eTNezQar3S6OAB4hahP iw9eeIn7m7PzlPcY1O9jxQ7fOjExoZwWVMWhLwTyIAJxSdZDoqw23G+WEicvNH2xDOMe ZeI4Xd2rAkatbIo37W2bkRvRdvH1bH9aWXgbL0FAAENV51Xm7cTqPWp30WZ7D5v0axF2 kNiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711578592; x=1712183392; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=a7hfzMDD6Cf+PT6Udlfkf6Vck2EoOCaENymKmzHzlvE=; b=V4BNUGBlGeuI9Mq64O1etBT6L0acoOd5vGvX562Giy073p13e+JfLZNnN8nd5/68a2 XBq/0IkLFqoeVhhRI1ud8CRfMSrfRAIpIH5ZXE0ybKO64/UBpt8PaEDwNYcCOVuBh0DL WZ+s39KMYh6Hmc49XApNPn4qPa6KWFr8DQ8ebtakgnvUxuhLv/rabRvrIq3VUat0peHK UgydO2/5g3Twc8XnFcYj2KeHEgHpC9zvzAr2p2iNxCSU07UPg6QZP8UHdjZhR7HZpC0M NWaGjQhpyqD/gRj966z7b+/eew2oaE7SskaQ/d0z21OGWufeGOSSmNh0Ej4iyWFfM2xU MSbQ== X-Forwarded-Encrypted: i=1; AJvYcCVgpWdR53uRfrDVPTpPciI/SpBjGf4vLPE+imtx/P0J7WONx4MuxzFQqhOuNbctScCPg4ZKFEVYDvUZgQiu2ZMO3902TeUnbgiEVQdP X-Gm-Message-State: AOJu0YzoFd92ge7gws/0nQt1qMxGRqDJ2pr/zG0u6aiEVXjbFW/idPOa 4iyafEBo1k7p5WKpwivNo2t9TYP2ozoCJ1oanSf1hd7wdpmkdrA5af9DZhnnlTjbT4vkahWi5BC LbZlaJgKvVKC4xD687hRz/NCG1rEiNn7I+rfO X-Received: by 2002:a17:906:150a:b0:a47:3469:d75a with SMTP id b10-20020a170906150a00b00a473469d75amr498589ejd.67.1711578591788; Wed, 27 Mar 2024 15:29:51 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240325235018.2028408-1-yosryahmed@google.com> <20240325235018.2028408-3-yosryahmed@google.com> <5e394253-4f01-4172-998e-bbf3d82de6b9@linux.dev> In-Reply-To: <5e394253-4f01-4172-998e-bbf3d82de6b9@linux.dev> From: Yosry Ahmed Date: Wed, 27 Mar 2024 15:29:13 -0700 Message-ID: Subject: Re: [RFC PATCH 2/9] mm: zswap: refactor storing to the tree out of zswap_store() To: Chengming Zhou Cc: Andrew Morton , Johannes Weiner , Nhat Pham , linux-mm@kvack.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Mar 26, 2024 at 7:25=E2=80=AFPM Chengming Zhou wrote: > > On 2024/3/26 07:50, Yosry Ahmed wrote: > > Refactor the code that attempts storing to the xarray, handling erros, > > and freeing stale entries into a helper. This will be reused in a > > following patch to free other types of tree elements as well. > > > > Signed-off-by: Yosry Ahmed > > --- > > mm/zswap.c | 42 ++++++++++++++++++++++++++---------------- > > 1 file changed, 26 insertions(+), 16 deletions(-) > > > > diff --git a/mm/zswap.c b/mm/zswap.c > > index 1cf3ab4b22e64..ff1975afb7e3d 100644 > > --- a/mm/zswap.c > > +++ b/mm/zswap.c > > @@ -827,6 +827,30 @@ static void zswap_entry_free(struct zswap_entry *e= ntry) > > atomic_dec(&zswap_stored_pages); > > } > > > > +/********************************* > > +* zswap tree functions > > +**********************************/ > > +static int zswap_tree_store(struct xarray *tree, pgoff_t offset, void = *new) > > +{ > > + void *old; > > + int err; > > + > > + old =3D xa_store(tree, offset, new, GFP_KERNEL); > > + err =3D xa_is_err(old); > > Seems to use xa_err() to return errno, xa_is_err() just return a bool. Good catch. It happens to work out because returning 1 would have the same effect as returning the errno. Will fix it in the next version. Thanks!