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 9AF16CEB2E0 for ; Wed, 2 Oct 2024 18:01:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0FF026B02FA; Wed, 2 Oct 2024 14:01:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 05FAD6B02FC; Wed, 2 Oct 2024 14:01:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E1A716B02FB; Wed, 2 Oct 2024 14:01:32 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id AA23D6B02F6 for ; Wed, 2 Oct 2024 14:01:32 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 4D379AAB18 for ; Wed, 2 Oct 2024 18:01:32 +0000 (UTC) X-FDA: 82629429624.12.D9A494E Received: from mail-ot1-f50.google.com (mail-ot1-f50.google.com [209.85.210.50]) by imf16.hostedemail.com (Postfix) with ESMTP id 665AE180018 for ; Wed, 2 Oct 2024 18:01:30 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=IqjiS6Dd; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf16.hostedemail.com: domain of nphamcs@gmail.com designates 209.85.210.50 as permitted sender) smtp.mailfrom=nphamcs@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1727892050; a=rsa-sha256; cv=none; b=tUVbD9ujhSPel4SICSFVazJ7Qft+33sV5yLOLbPp4dcxKE4HXGNiGMc/5FYSvKJitkc5Kn wwg7GYB2HABf4Oq8ZqMdoic9Y4BStLqgcPrMtkdXxxEWbrUOJl9HA/fP1B28uAin9XwRS0 i5zuimcKgoD1CyCzRxGJxNhEIYxfil8= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=IqjiS6Dd; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf16.hostedemail.com: domain of nphamcs@gmail.com designates 209.85.210.50 as permitted sender) smtp.mailfrom=nphamcs@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1727892050; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=zBmVpJ2lS0EfBt11YWK5IEU6NV/O02N/XsQBY+RyDpI=; b=rV6GQVFiaVPZwHYXBzNfcN05TvW+VuHVkTg1xWE0YKqTXQY86ht9LiGVZ3PP8zo/BJea4A tZ8HXywM+Vs5iLBNocXwGCBI8PLZv490k4Q212qOqalC0KxNh/hQ/QBI5UsiXLByms8Xwn lddGEXHn6UA+g6OTdQe5l/TlMJuDmr8= Received: by mail-ot1-f50.google.com with SMTP id 46e09a7af769-713aebfe8b8so53859a34.1 for ; Wed, 02 Oct 2024 11:01:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727892089; x=1728496889; darn=kvack.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=zBmVpJ2lS0EfBt11YWK5IEU6NV/O02N/XsQBY+RyDpI=; b=IqjiS6DdeanCLHEsbtmaAq+PwyNEqKYaRhkOj0v26jzFLr4tEt7IJzIp9CH1vTWaJy Map0ZYN+yYlgVOn3BkyI4+SAy9Ne75xNeE4V/qeTGdvX8Up943WQMrOMmPpL8xagKeCn TBwEucjUE7YZrmtWcgK/5ZjS/QpD/seMT6YNKX0vDxnKk7LjR06Blu3KRpNiJ5obaEUl jv3plS5v5+INpmBpLQS7/SZ1Tj8SnHJO0F+ZvpMuK1O3cZQ+PdQNMO8dFxcgqi896mrH Bc2DMK41TnCFf/cWC7FIWjngaj6EDJVTZfXr3C7N0D0+U2vLgPqbLYnHrAuXYA84PmyG /1KQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727892089; x=1728496889; 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=zBmVpJ2lS0EfBt11YWK5IEU6NV/O02N/XsQBY+RyDpI=; b=dRcGcb+/B+GU4U6TuMHnVGox4LbcObnr+v3S143RUmw/jUKLdNCUCvQsv9EY84uuCy JN0cBmWLNPXN/EEFOo6uaK5zkAq9fSBNODj1dltOBvUkR7wGvnlBMa4OikfB/RKq7y9L 2XmGUb5E6AAuABRcf2eqt4M3blPGVEqp/nSVYy7AEVEhuiUe7NSti4tpKHECo7lDlTCt CR8oV/rKOZYrhmfnH1AX89Uyra98Z9fjQ1xISMzYyK1q/JYlWffJSs9RktFeU9s6GE5o Kxt0glSkrQ1OFE44Lw5LAJBs+r0sG8AnMfVkAv3aNdV3p78cw8CkzFUFUrewazFv4pmH tOmQ== X-Forwarded-Encrypted: i=1; AJvYcCWBt96hO+igSa2G89C4WcqlU1tiZkr1zbbUYXdl3i9bkoTSaI25D8rn9vOpDPCi692FJN2r74S2oQ==@kvack.org X-Gm-Message-State: AOJu0YwS4oTo66JTfSA9fnJpvXa8vHQ4jmceqi+NyB3bx3BrFnhDJ842 qybV2AoLFlwFZRFkGR/BARM99eq1kMe4ot5g+kZOfTlnyQk9m43KRVOLW78olxHKCdL6i5JK+qg /5sQex0VvgHQFy89eKdb7kI4UEF0= X-Google-Smtp-Source: AGHT+IFpdVK0i5krQWsg7wpQTYmxLMD2SJ/37I9vSqzsKw/ix8i2U9iC8sZsEjqctodizk8RYjAjuEwSR187MYF57ug= X-Received: by 2002:a05:6358:9985:b0:1b8:33f0:65e2 with SMTP id e5c5f4694b2df-1c0cee6a9e2mr260890055d.20.1727892089208; Wed, 02 Oct 2024 11:01:29 -0700 (PDT) MIME-Version: 1.0 References: <20241002012042.2753174-1-nphamcs@gmail.com> <20241002012042.2753174-2-nphamcs@gmail.com> In-Reply-To: From: Nhat Pham Date: Wed, 2 Oct 2024 11:01:18 -0700 Message-ID: Subject: Re: [PATCH v2 1/1] swap: shmem: remove SWAP_MAP_SHMEM To: Yosry Ahmed Cc: akpm@linux-foundation.org, hannes@cmpxchg.org, hughd@google.com, shakeel.butt@linux.dev, ryan.roberts@arm.com, ying.huang@intel.com, chrisl@kernel.org, david@redhat.com, kasong@tencent.com, willy@infradead.org, viro@zeniv.linux.org.uk, baohua@kernel.org, chengming.zhou@linux.dev, v-songbaohua@oppo.com, linux-mm@kvack.org, kernel-team@meta.com, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspam-User: X-Rspamd-Queue-Id: 665AE180018 X-Rspamd-Server: rspam01 X-Stat-Signature: obzqm36j4osmnufms3ry7sbo4gk11t1k X-HE-Tag: 1727892090-919467 X-HE-Meta: U2FsdGVkX19IG8//9tonOh7Bsik2WCnbk/NTGO7uXUlbBkOy3dzR4NikOY8dJJA0KcJ/bi/GyQfhKF4tNfBFMMPT/fU8H1c8+QCs+6FOF+Z/jxph/AY+cNPfp1nfZ5x8F4+oMD8xrmBxYdQhd9zLA0/Nw8BP8sJ+rvshnb+zfY8D0rNWUsXVpEnCjirAXOghHVw8jXpnOiBPqOdlDwJFqxEGpi34WFsst9kTRa8bYJIjKx9tYQo1FWZCQzzBWnErTil+uxzdLt8rPzLeZ9SxYPVpm2Wxi8vG8h3y75mQmXtf4/NRKuX68DcI+NFoI5J08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xAG6oLDk9Tv+2WI/R X-Bogosity: Ham, tests=bogofilter, spamicity=0.137780, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Tue, Oct 1, 2024 at 7:14=E2=80=AFPM Yosry Ahmed = wrote: > > On Tue, Oct 1, 2024 at 7:06=E2=80=AFPM Yosry Ahmed wrote: > > > > On Tue, Oct 1, 2024 at 7:04=E2=80=AFPM Nhat Pham wr= ote: > > > > > > On Tue, Oct 1, 2024 at 6:58=E2=80=AFPM Nhat Pham = wrote: > > > > > > > > On Tue, Oct 1, 2024 at 6:33=E2=80=AFPM Yosry Ahmed wrote: > > > > > > > > I was debating between WARN-ing here, and returning -ENOMEM and > > > > WARN-ing at shmem's callsite. > > > > > > > > My thinking is that if we return -ENOMEM here, it will work in the > > > > current setup, for both shmem and other callsites. However, in the > > > > future, if we add another user of swap_duplicate_nr(), this time > > > > without guaranteeing that we won't need continuation, I think it wo= n't > > > > work unless we have the fallback logic in place as well: > > > > > > > > while (!err && __swap_duplicate(entry, 1, nr) =3D=3D -ENOMEM) > > > > err =3D add_swap_count_continuation(entry, GFP_ATOMIC); > > > > > > Sorry, I accidentally sent out the email without completing my explan= ation :) > > > > > > Anyway, the point being, with the current implementation, any new use= r > > > would immediately hit a WARN and the implementer will know to check. > > > > > > Whereas if we return -ENOMEM in __swap_duplicate(), then I think we > > > would just hang, no? We only try to add swap count continuation to th= e > > > first entry only, which is not sufficient to fix the problem. > > > > > > I can probably whip up the fallback logic here, but it would be dead, > > > untestable code (as it has no users, and I cannot even conceive one t= o > > > test it). And the swap abstraction might render all of this moot > > > anyway. > > > > What I had in mind is not returning -ENOMEM at all, but something like > > -EOPNOTSUPP. The swap_duplicate_nr() will just return the error to the > > caller. All callers of swap_duplicate() and swap_duplicate_nr() > > currently check the error except shmem. > > ..and just to be extra clear, I meant WARN _and_ return -EOPNOTSUPP. Ah ok this makes a lot of sense actually. I'll return -EOPNOTSUPP here. Do you think warn within __swap_duplicate() makes more sense, or at shmem's callsite make more sense? I feel like we should warn within __swap_duplicate callsite. That way if we accidentally screw up for other swap_duplicaters in the future, the feedback will be immediate :)