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 AF87CCF318C for ; Wed, 2 Oct 2024 02:07:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0509844016D; Tue, 1 Oct 2024 22:07:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 000DD440168; Tue, 1 Oct 2024 22:07:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E09C044016D; Tue, 1 Oct 2024 22:07:33 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id A9C41440168 for ; Tue, 1 Oct 2024 22:07:33 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id D95F8AA960 for ; Wed, 2 Oct 2024 02:07:32 +0000 (UTC) X-FDA: 82627025544.28.BE75D19 Received: from mail-ej1-f44.google.com (mail-ej1-f44.google.com [209.85.218.44]) by imf12.hostedemail.com (Postfix) with ESMTP id 02B314000A for ; Wed, 2 Oct 2024 02:07:30 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=R8Pz7VfR; spf=pass (imf12.hostedemail.com: domain of yosryahmed@google.com designates 209.85.218.44 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=1727834723; 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=SqgRp9ksyb7TqEHQlqN1wv+FBNWnFa5i6BHVz1zWkmk=; b=TErJCjNA3u1lMqLGXWKUing2bycdxh9kIDUqw9P8yOJJS8iG7V4JWlIELroAWRqdxmoL/z bh9tIeBYnELaZiwTseTEVnSIzxdgUi8AkzVUPrffs2H6WmzQuhKzNhqSFLy+oN7ZpPJNHB qkuINsdWFj/rHzs91rhXr1VCuEFGSTA= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1727834723; a=rsa-sha256; cv=none; b=KOKDqjQJ6UY507h3OotP4ixGROHNx/Qvjok8ZflOQyRDcKARR3EkmURTJZGB/LcOKQbYlb FV4aq+PfKCsTw7dkaH+E1o9sEDDyLvOBbLaSSn1Lbi3gA7APHklz5T7aAoN77Dw8AQgDdw 68jobOodLySbXOcaN+CpSudgrIwNGNY= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=R8Pz7VfR; spf=pass (imf12.hostedemail.com: domain of yosryahmed@google.com designates 209.85.218.44 as permitted sender) smtp.mailfrom=yosryahmed@google.com; dmarc=pass (policy=reject) header.from=google.com Received: by mail-ej1-f44.google.com with SMTP id a640c23a62f3a-a93c1cc74fdso942441566b.3 for ; Tue, 01 Oct 2024 19:07:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1727834849; x=1728439649; 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=SqgRp9ksyb7TqEHQlqN1wv+FBNWnFa5i6BHVz1zWkmk=; b=R8Pz7VfRXM+gZ3+KsjQEJfkn+VFFVMpUcbNhDgpPWUHp9SKhCtSC+yTv0Ny0Elo/2A 6qUX00WghQTxcYNkd/zStbyvars19/hfg4Rqe5wZu6a6AyEp9ulQppwWOZc2FWQKbhKL 6JhKzgWTDrSVQP3b/ZqrbS51OImQvXnNjD4dwPGd3l8thPHvhfMdzBlPn4+CuGg3VvAp 5sdcccQQbocuNYfEJjIQgz1CYDe7ym1lcby+YUhQ65U4DJIYi51OmQ/hwnevMLuT0tL+ yXFF7GXNsCy0VtmGStlOdGy8qlv2reosJ8Id4B4DiwWctIcDuEA6cfo8qmKEwto1SlVh nTjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727834849; x=1728439649; 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=SqgRp9ksyb7TqEHQlqN1wv+FBNWnFa5i6BHVz1zWkmk=; b=GAVK5ecTsovbQT7ABxNPVUW7ZzzgWV2F01zHFD/UtV6e7VXsp3Efr/ooiX90Ut6Utv wpAnToD+nMeHXRku6JvcNixYLBW11GrS/+JObqaKfPT6bnGN8mo5o4En1/9+3mB/jCbi gAeyNAb87Zy1HbQhnumSeSfwhUbnyBfKSbvuOOyuK48GQmUmhO0kxrqeN9veRYNOcWBW BAGVoX32GZ0L/rUmx2V28I72xAEZWvJV6XFzj9w9tl7cDolZDUeBLKKZoUqj+Retd1v2 2uHg9ZS4vS45v5bVP6ZgDcACC2P67lI+lxcTYzSqUN0W5AyPjGppaz6Q7pEIYVmBiXNy 6kcA== X-Forwarded-Encrypted: i=1; AJvYcCU3GY6pqsSZ5aDxdtBKmuckhnlgnsE+Ta/e3wk1R7boEmVmGMX48UOlLICs6Pcugbh8cLf+H02brw==@kvack.org X-Gm-Message-State: AOJu0Yyb4w3HeZ1SyE7RYfTlDE6S5PvgZ5nu7iptAIebE3zKnYM9Xmwu g1t5HzmjvmUOG+I7q9YO1QBncjqeBRQw22fGPnNVirQvATeValLhxPODpbMSUqD40txBNVlJG5C U6P+FiumuIoGB5sVpBNt1QjbyXT8mAYypq5U3 X-Google-Smtp-Source: AGHT+IEuRycV2lyATx7SaAlaEJeUlJiYknVz8zfaj1/Pio6g7o8+pOJ5r7VtUHQGnEC/26nPfYiAe7uBfU6k/yfUhE8= X-Received: by 2002:a17:906:c113:b0:a8a:7027:c015 with SMTP id a640c23a62f3a-a98f83fe799mr148466166b.56.1727834848839; Tue, 01 Oct 2024 19:07:28 -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:06:51 -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: wms56dpxmzpjadko41gousds5w8u3aku X-Rspamd-Queue-Id: 02B314000A X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1727834850-606904 X-HE-Meta: U2FsdGVkX18CDtPHiynY0VbAei3/nRj+AZH2Vzr7cTLSDJ7XLx2EGD3rr8oUJgPF5K7xKKMCYkIxaLPXLIQgFhmD/GaJwybkDAyevSbIKUrhfyHQ5Y6XXemewN2nDQoSwZ1HfM7TUdSeH9kaF4DHHjpswhLwt979Z3grEh/3yCOnvxruubFpeRylbq0kKIILfGoy07hVtqWPTvcvbwdC8FdH4b3Aa/dzJgUFm6tjENvgZByG3ZtMdLwyV5yvpiDQp3VFFP3HA0eDkm3GWB3Kw5A8Tf8pmlpSE2gSq9QvA9klsuAvbSQWOzIHck7UOIF3giPAenipWk9Oes7Wj0Thd3Hu7q9C++6tIHcqeN4a6Vl/F1xQcG6sSLuClnhtbAVToXBSgeek7oL6UaOqH7RMTi5RAGLNy6ThDmFyJNAVdX925UJETwz/JnUK7Cc4p0jJDJnc88a9wdQ5MuvB/Q615CYZjpXTQ9Q7PQBb+FDOVO9nJJsgI0itqNx9CISi2j1tl1UL3Nx1ReMS5EP70sic+y3dZSCqwx6N1z8IxMAP8oHm9lV7o7ZnqzAzVN7WMKLP5PAfxmVx9NQZ5vtOzWgsjE4SB2Hu3Bx0/2ri1C/xudele5HxK51ygegEbGviLeZwQWkpy1jzsCP5RBVmVPGTLPu1WHJea5/98ka3M8MaCZ3we6H2meRHP+lqz4o/9DLh0WcmEsJUWPB/unU0I2JU0gtozcq015qOVqxBuIGra0IeqgLYsCRBJGw2Wh66reau/GdqWgJE2qaTj9pdwtrrsG/0YAxgBFZtlEnXFUBR+ed3jdiPMHQ3rUCO3wW13V/5nNKELS9/1jTuGLGbnhY/M8CVt+v3FRN55eCIpbF0JyytRU7250rqQ14eFpj8v4LgJoRD8rmMehnl4sVAPV8HaUhZC5FRYu1JAaleQCxLdIQooEGvZzyyonjpAMvQV9Q1oFNGNJX+Evg/IE6CjO7 W8shQsW1 mUnqQZtnULEYtlhL5RGkfTkG+fRRrE/oDJqfLbz3O2hFMh1t5cj0V4I/Q2ChKCrV4asxu8FjJKsrVLHpWRf2++xPrQkLW2HbDhuObI7qNXx233gBnZaoO6W8FAfjQVuBjIRI8myjhbpYj5FOKeP1utPuFa38JD5N+tzbWvy7CP4fKTNreSK+a3My8de8j4UIgBbra8Pg6k6FSqcz0oASF0ah6l9vK62rKGVStlmX4EPZxOuBjRIvwstNASCtwZFwRmyGewpqkt5zfqB9E02BC7hTm1e2sMuzI4A1P X-Bogosity: Ham, tests=bogofilter, spamicity=0.031648, 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:04=E2=80=AFPM Nhat Pham wrote: > > On Tue, Oct 1, 2024 at 6:58=E2=80=AFPM Nhat Pham wrot= e: > > > > 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 explanatio= n :) > > 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.