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 24CEACF3189 for ; Wed, 2 Oct 2024 02:14:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9F1EB6B011D; Tue, 1 Oct 2024 22:14:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9AA2F6B0125; Tue, 1 Oct 2024 22:14:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 81AC06B0123; Tue, 1 Oct 2024 22:14:14 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 58D6A6B0117 for ; Tue, 1 Oct 2024 22:14:14 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id BA0921207A5 for ; Wed, 2 Oct 2024 02:14:13 +0000 (UTC) X-FDA: 82627042386.17.068516B Received: from mail-ej1-f42.google.com (mail-ej1-f42.google.com [209.85.218.42]) by imf09.hostedemail.com (Postfix) with ESMTP id D66E1140003 for ; Wed, 2 Oct 2024 02:14:11 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=lykKYv9F; spf=pass (imf09.hostedemail.com: domain of yosryahmed@google.com designates 209.85.218.42 as permitted sender) smtp.mailfrom=yosryahmed@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1727835123; 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=LFZOZJG10pd69hbuLm2Ben3C/v5CexJ3Fb6zstX8Vak=; b=JnXt4cgPmWIVgAhOuVqi2c1ERSNhP5uMCfuzN7SucHyYZIPfBFs2JvF/hw5ngj7FPKJ/uT HinCKDCQ0WsyWICBsuUVR6OCL4JnXBbDBkoRuO1yhuVxzMsWrbPsa571tDX4D1jydD1uWx eDcI+ziaar0WoJkwSO3HTLtQssz10c8= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1727835123; a=rsa-sha256; cv=none; b=fuOHiu4QhW/C7AOqBfqGMIXuF3FPx8gpKTECldnIzNwDqQE2r9jMe2Nw3xushcyLkmy8Uc G1nmIvC8r13Oo06EsXxwhqfAOoJv4MqvaON6XKHutVQFwfOqTr6UDu1/kIb6c2PwAczflq ygJbAkWD22zOAv0YSTIkxZKGT1FBhKM= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=lykKYv9F; spf=pass (imf09.hostedemail.com: domain of yosryahmed@google.com designates 209.85.218.42 as permitted sender) smtp.mailfrom=yosryahmed@google.com; dmarc=pass (policy=reject) header.from=google.com Received: by mail-ej1-f42.google.com with SMTP id a640c23a62f3a-a8a6d1766a7so106407366b.3 for ; Tue, 01 Oct 2024 19:14:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1727835250; x=1728440050; 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=LFZOZJG10pd69hbuLm2Ben3C/v5CexJ3Fb6zstX8Vak=; b=lykKYv9Fi2G6kY210Kx8UtbFiAY+JZquttmHeIZVCmDxCHUY1xf8RM1Fqym94Lqha0 IHwGQ3Ut5xbmI5a7WCRIe0GGNvw01uIqtkY2mENc6vwPJlVzcfeWKiIPotbWZxZ60W1/ qlGJjuq+52uCyCTI/IBLt9xKy3gWgjaIe3prDC0x/pGtBOjHOW5Mgr7rqcNT/aic+qnt uEOL3/Dcnn4z+f4dLTgwWPGKxJYcq2Yf11M5v/hRhS/l2fGr4MQU2e6WwHXBEPxynuQV AihGGz+9YAAwzRgRvaRcqpAkiRetEGB+x24oI6VErUlG3TrnxjFSKSx24MVK4R+Y0pqK KOJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727835250; x=1728440050; 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=LFZOZJG10pd69hbuLm2Ben3C/v5CexJ3Fb6zstX8Vak=; b=FdIdMx/FrqwTogFMNj9vh8q5JyI+AEbCIETvCHionzpolX0SHEmA3HOLiCM9kZxHRb ZfNSHpmec7Y7o9quu4snpHrT4arfe7MwHt+ayHDwgLGjz6hwAjy4R9FzzUtJUF7WPDca RXc5kmXr5p3Rc1aGigjQAUvkozyOi1MXGWYzPek8AZnPvgLVD00qXYLFj5zOAQS6XyCj 9jr3N9wwhOsOfhlXmog7hi96Xme78z7g+d8Oa5ItHgzXGeovz4j0iagxaYS2ISMV5gQi iG82orx11LW2IqI2lDGeVyy6WDtcM2mieCo3qv5DeASICjorlO1tjzmvpEOyFIFo7u2a 188Q== X-Forwarded-Encrypted: i=1; AJvYcCV43R6AXFIfDzD86P4tqMNJ8JZcQaWIDJxmmglaVGi9jN40Fyls2PqG8pWWGw4oWyDHkTmUHtoPtg==@kvack.org X-Gm-Message-State: AOJu0YwbotZq3ZI/6esriLPVktm/BM3tsY6rdQ7ieFZ2MZqx7rmEUDJe dMWFYCXuYeTNoeYIWS+DFKa1/6ne2ygFuITWRp/18uzAmwefawMLYS408IWRPGJ0dYMizewjSQ9 AdKEQlG/3GsmUIJ7DlfwLUEmIGVqiuljJWSun X-Google-Smtp-Source: AGHT+IEVqM19Wk6qPNOiyciF7UFwWfzW5gunfwWsysiS0/KPc2RiKcZFnuHkx4KIlQMM47m/x7cZl3B9Ya+7OwkOl0Y= X-Received: by 2002:a17:907:3fa4:b0:a86:9fbd:5168 with SMTP id a640c23a62f3a-a98f8207a8cmr127805266b.10.1727835249798; Tue, 01 Oct 2024 19:14:09 -0700 (PDT) MIME-Version: 1.0 References: <20241002012042.2753174-1-nphamcs@gmail.com> <20241002012042.2753174-2-nphamcs@gmail.com> In-Reply-To: From: Yosry Ahmed Date: Tue, 1 Oct 2024 19:13:34 -0700 Message-ID: Subject: Re: [PATCH v2 1/1] swap: shmem: remove SWAP_MAP_SHMEM To: Nhat Pham 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-Stat-Signature: ohqsyn7asjarpig9yzr9o9974cm4cxwk X-Rspamd-Queue-Id: D66E1140003 X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1727835251-53697 X-HE-Meta: U2FsdGVkX1/7yGzL/5fKi+MZhbAoomu6h5czXfO3ZJh5E13I9dNGQBjrR9CrsucPqn6o6Rp+uNoevqvRxU388EfvjOM4nIMPbVounMelW7wdR0xSVOqOhp7/7r8XhMB9Ll3Xio3S0wVpcTauGFLkaZJyq/4qwizBFPDunGZZeongv8DyOFClliTDGDZxZXay49+7wkcJPyfd/3Wy5+ZLPsUOzF/FSOUOJ+tcQZKJya4D/Cd46zpE4SI6tc133pXlM4KxjKhinCagveDLYVwuIOpvVBvGnIU/buAvlHPeSNsdzI0v7yQa6dm2HL3qXKscMyttpmjCbai2elV4Q8mWF4gtmns95sRU9/wgGa8QFvWS+qVoQ4OnQk+cB9chuxbLY52qcirK3+rcUfu/mg6LD7X8CNeqoWyW6SEqOqynl1HQSkbDd1OGfyJub9fYmqku9fisnGLFbMdKvSa9+0UhQnHvS5BdA25C82s0Q4qcM66EVytM6GEDmLX8/xnDMTFnIRczQkv9t5kWN3zyiw2KyiUT8C0iBJ5PviImVd6DtKSJDjOBsMPYzJSDM+PjfwzGoR7IY1lwHNGi0trtnxv93YhxVmGRV+Bqb5HTt4c4X/YwXylf+WoSrDbCeBTd5IM0yOIZiIl64ALxP/IqIrIq0ByGN4X0fBZj8dE9AHqwNoGv9UY6YYAzbz6SKnBovwCklScDdH/JNvKn+N9efAK9ZAtaKGuocNro9C3LfSDtdViMke3ruSE0zKs2kLOvwRGVfShfA33TLUp6EZfsik9JkYHNzhNqgPVCElNX/2EewIN5i38X/kcO4NNryanrtkloOcKSEWVwH/2hotwjRrjtT28DSv9KKp6cVls3T+pMp4dAQg8LH2bMkjgYf2UEsY3Pneyh4PWJ2kWh2LQ25+XAzEyiAMhiCs2Ayst3gMTPomcT5kf+QKya1VUn3ilBD6foDwS5/Xg51aCKM0hRDbX bbPh9s60 UQ28gGGw/YIYsyOv78k5fFqGZW9QMHPmWRWN48kYx5tivcDcYJBgkXxBYwasmABFpyg4wQMY0yczzaWAJH9hZ9Jhg8QPvFS/saHdStzqK1sQQ/qVYqMtGf6LvJT/bCeLyfWRA7E7tQYxoUYHCLeR3QkqX8GlWrW29EyDfzMXsRAw8CaBBIGAf+NZ2dnQbyMwd45KRAHCe5ENriKD+9eSc6xFpnjyYD4NjTviGWc6mEhOknpuZ1hLuNJHqGSPc09OB6m/z9U62EyV2oQcgLrY+zLkS/6fqcXLc4QAL X-Bogosity: Ham, tests=bogofilter, spamicity=0.279809, 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:06=E2=80=AFPM Yosry Ahmed = wrote: > > On Tue, Oct 1, 2024 at 7:04=E2=80=AFPM Nhat Pham wrot= e: > > > > On Tue, Oct 1, 2024 at 6:58=E2=80=AFPM Nhat Pham wr= ote: > > > > > > 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 won'= 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 explanat= ion :) > > > > Anyway, the point being, with the current implementation, any new user > > 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 the > > 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 to > > 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.