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 D3D64CEB2E2 for ; Wed, 2 Oct 2024 18:07:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 65BF54401C4; Wed, 2 Oct 2024 14:07:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5BCAE4401B5; Wed, 2 Oct 2024 14:07:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 40F414401C4; Wed, 2 Oct 2024 14:07:21 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 15C3E4401B5 for ; Wed, 2 Oct 2024 14:07:21 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id A1947C0DA3 for ; Wed, 2 Oct 2024 18:07:20 +0000 (UTC) X-FDA: 82629444240.21.37BB191 Received: from mail-ej1-f46.google.com (mail-ej1-f46.google.com [209.85.218.46]) by imf04.hostedemail.com (Postfix) with ESMTP id B412D40007 for ; Wed, 2 Oct 2024 18:07:18 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b="k4c/8yQF"; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf04.hostedemail.com: domain of yosryahmed@google.com designates 209.85.218.46 as permitted sender) smtp.mailfrom=yosryahmed@google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1727892344; a=rsa-sha256; cv=none; b=TQtGDSTuv8vmOaSuxyQCoxdzCxiLpToVZXMXSjPqM6Uzvq3zwD1yycJCwmLQ2I+IzSmQDg 9otusW5+g7o8EMfXt1X0uBeQn0VttamVvJYWpJJU1ceg1pgJ7QQL00HXcxgoB29Qdr4hSS 8s2IC8+nVdwoshy9h1KMh3Dgrra9T7A= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b="k4c/8yQF"; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf04.hostedemail.com: domain of yosryahmed@google.com designates 209.85.218.46 as permitted sender) smtp.mailfrom=yosryahmed@google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1727892344; 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=DVXPE8LW0o+h5erW2O73EH0JqEFz3MQVW/H/il1Qi4Y=; b=trsYtxuMzllfe+v/pQ+TN2UDposqtTVGZX5asKqnOzw9QAhSkpm9AXWCG3IR+biPaZasfL Hk9b8o3sVDb+jRIzjkbjPtjSNpf9Z/4kE5Bp/rbFae7oWQ/WrW8g1WAE0y0sFQSzIiM2bd tqre+PQNYcEBFWH7QhmYYgc8BhjA7A8= Received: by mail-ej1-f46.google.com with SMTP id a640c23a62f3a-a9909dff33dso2650266b.2 for ; Wed, 02 Oct 2024 11:07:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1727892437; x=1728497237; 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=DVXPE8LW0o+h5erW2O73EH0JqEFz3MQVW/H/il1Qi4Y=; b=k4c/8yQFsPW3YKQtMoPtdoBJdu82EOyggAQ039p0/ooKZGsOkQMrn4fu4f0tZI+Xn2 BZgT/8Fa93Vltgdaes+yqA+KH+Wr5xXO890svyAl1Wrlo5OQVcxqa+OS/sMoij4Kn6nN NXB+K0KIm9m7ceUZjzOMMNDR4pHVgJjjMmdfT4yKRKQafFQc332Wdo8m6ahxTBf1sbLo DvtEGVmSgK+wgatpTOwviNggVwAyK1LZ0GEGb9h7W7M4TdLnG/fZR/bMubRMFiCjxlFK U1Mp2UiqGQIlPA6yOzmEIaRXWS8zJuIuOVk16cqMfbJcOfjnbZPXLWqlVvjfzrqHR+TY Co+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727892437; x=1728497237; 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=DVXPE8LW0o+h5erW2O73EH0JqEFz3MQVW/H/il1Qi4Y=; b=LNbJgz+zLpYmI4bQcxdENlJWSNWeh0WKLk5PCN61LumFr7nlqv+3HiL6/Rk6V+wEvD bJACjIHxKuZCX18+eDklLpVBQZnoB4UG0mZo79aQBfqsOdEJVvYGb9dvZk5XyeQy43yt VIQdU86NZhck9YQM7kjsFG5DUFXIChxh6yg2tTLG1eFY0hkqgCXO+WNNr659spxqZtIQ xbFkTRqnU6cXIm1qKZBfqrM/ihVnVnXlx7WlJvcZw/tv5Jjf+VBBCzsiMx8pK+0NKn0+ wRA5B1N+akAsg2gYD6VnJ47qBVMqEL3ZA35GmsntP5qRECxaBWGHIgrti3xfZ+Twlh+Y UOiA== X-Forwarded-Encrypted: i=1; AJvYcCU+eRC7zWZRcIdaMeQLg4eSHvTNo+ldS/e2LtWeYZdX+SXgO1KZTLYTM/1AfUFJC1FOg/VL303R/A==@kvack.org X-Gm-Message-State: AOJu0YwBna1ew6nkFLV+X/Mcw8IhFArJ6G32TSftrBnWGc8HR20MlPRF 2k9PNCxwy7HqPurMv+Elms2Uh3w2KgtQ4ZjhanJ2uA1K+IIIEMUUpjvcI1ESC99xWXJNQdjVAPD vXpD5AS2Day2eV73J7xTgXR/kTzdaJt/Ju2qk X-Google-Smtp-Source: AGHT+IFnVdqpPsW8lCBi0z9jZOfyK06xdivLZmdsWdN3iWqdFCCajHhvs9K8jIIN5LrJNP1Ha+2BEiAjDdwW2gc0BPQ= X-Received: by 2002:a17:907:3e8e:b0:a86:9644:2a60 with SMTP id a640c23a62f3a-a98f81f6817mr415127966b.6.1727892436723; Wed, 02 Oct 2024 11:07:16 -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: Wed, 2 Oct 2024 11:06:39 -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-Rspamd-Queue-Id: B412D40007 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: f36bb37r39khd5ibdezp5of9umd1pycy X-HE-Tag: 1727892438-644945 X-HE-Meta: U2FsdGVkX1+1dZKRmXcWffUiWnQ8IU6rn0DAfApYiDzM8brUF1t6tkEKRqPi4WabcX2gRieG5poCI7HqIw9Yryk1eMgnxdhHYPqniVnTmrhjVpgS3KO/XiEXw/ocj0/USHkQFMPv5CMr05Ld8OxKZm/XhbUOxXGS5h10Hr7wfLBLNJtoJCVQD9uTXT3BzDqEdKLZFPRJBbXn28TZmcyY0A2M3cLkqy4u32to6cmAl2ByPO0g+sqXsUyA4YqPjYOWbpqVs31hNjAIKXi29L+U9EM4E80bYZdQu6uQA21W7leYhznLcrAhtOPjFEL+Zpjur+OqP/tyK/v1B9sQvptsLhm8WoF19JetcYfMm/lCLhAvDZF+SJl7QCoAoAAKkBaXAcDzCRX2RJgX5/a6pnGoam5tMMe2QKsAbiknZPEIfp3b7SqpXZat9LzEh1Qiei0PGwIRliLxtQQtvu1FPqS87iIMUPpXGl4/OkS0wkMqwE2VyspGY9Vt78XhwpKtIBSC4mwdGlM2ohEJr4toHcZUD2FMzKIJLcPilb4FDOvcMbUd2nErkQ/dNZkxcoGNy4x6ltKn6QtgUq5tgTiX95vem/nU+omGXyPDKO9YRe/6iBE2hZX2BEzVKVRgvUAKvpcBUvXO6lFO66KtdvXEnX+O1ZOrspM6pj64xO0e35Fpyp5+9iSdxtvm1ubH1btk/zk0KzAgqy1lKNHyO6HiqNI3qPMdvvSU0XfvDf8S0WJ8guwUe6Pb6z7qUxEoNQJGWUnZNNTgC70NbqcAyVfc9/B3v6hzeMPGOwOuvRJHSopEIat8rWZ9NC3kvI+E2PW/iWTDcd1Ewgm3h+s2Sr0ZsN+WzKiMQlr+Dt4Ekw2iGW5B5uG9TZb5DWnf0BzCRsdT0IJATrHmPC32p1lL4Gn9Muvgth2yqJqJvNpcn2crBpfG0UFMrjaNRken5YpSL7upf5MI3TJvzoLZwriVwKXEZNK lPPd9prl pnoUqLPw3/eWQIIlwE+u5LZBw+TAz4gc9XjVUIQWlpdm0+8Z+bpghlJXf59N9s46uFnVLmbrK5EGpiotfe2chWKuz8CTKYfKNC1WNuisNNNi/wQ+B9JJAUrwd+ICMlJOEJWPqaEg7oOJ2+pKy2+VJ8GmEbhER1HDsCe4USC5BMtIqSELcLyQ/Xlu8dWX+BwhNL239kdQmVW96lHEll8TaV9uVX6ZgCIi8l4y3i5f6IPrbpvdk76B7I+p/cFyo/xGOx8Cflly2YkwiV0Ys7sw4B3qURPBEjsnzhFnC X-Bogosity: Ham, tests=bogofilter, spamicity=0.178290, 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 Wed, Oct 2, 2024 at 11:01=E2=80=AFAM Nhat Pham wrote= : > > 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 = wrote: > > > > > > > > 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 th= e > > > > > current setup, for both shmem and other callsites. However, in th= e > > > > > 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 expl= anation :) > > > > > > > > Anyway, the point being, with the current implementation, any new u= ser > > > > 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 dea= d, > > > > 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 lik= e > > > -EOPNOTSUPP. The swap_duplicate_nr() will just return the error to th= e > > > 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 :) I think we should warn in __swap_duplicate(). We can also propagate the error from shmem_writepage() to the caller, but I think this may need extra cleanup to be properly handled, didn't look too closely. We can also warn in swap_duplicate_nr() if we ever reach the -ENOMEM fallback code with nr > 1, and document there that the current fallback logic does not handle this case (instead of documenting it above the function). This will make sure we never return -ENOMEM from __swap_duplicate() incorrectly.