From patchwork Thu Jun 27 00:09:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 13713555 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 2780FC27C4F for ; Thu, 27 Jun 2024 00:09:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3FA826B0092; Wed, 26 Jun 2024 20:09:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3826F6B0095; Wed, 26 Jun 2024 20:09:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 224026B0096; Wed, 26 Jun 2024 20:09:32 -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 F40EB6B0092 for ; Wed, 26 Jun 2024 20:09:31 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 9CD75417E7 for ; Thu, 27 Jun 2024 00:09:31 +0000 (UTC) X-FDA: 82274734542.30.0807E9C Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf07.hostedemail.com (Postfix) with ESMTP id 13EE44000B for ; Thu, 27 Jun 2024 00:09:28 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=4tsWEX2w; spf=none (imf07.hostedemail.com: domain of mcgrof@infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=mcgrof@infradead.org; dmarc=fail reason="No valid SPF, DKIM not aligned (relaxed)" header.from=kernel.org (policy=none) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1719446960; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=EBkUb0Zod9PMNfEgCDDzkHALc55cp6jjtgA5Pre3tic=; b=tOZ2B2amMweMVm0zd63gtEmkM9waLoYASHCXCTOE8Xb7jVugZGo4RSuObaWJiT2vDuHcu0 bVMY7F/OGxfeEG+zZCX2hvI2bodxfSzh3Zbhk9X4Xj1n03MEWcl3ob/MsTeBwa8Ic3Z39j jYbseEjxdmcq99r5Hl03t9vr4rcm7U8= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=4tsWEX2w; spf=none (imf07.hostedemail.com: domain of mcgrof@infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=mcgrof@infradead.org; dmarc=fail reason="No valid SPF, DKIM not aligned (relaxed)" header.from=kernel.org (policy=none) ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1719446960; a=rsa-sha256; cv=none; b=71MRJz7QVIEv5W7XFnWduHlhtVRifSfoPYRTBWTSAL6tgBx+NuDqL1vXUsUzd/goJ+R27y CkMa5CsheG1UJp8Xr6GhJTmgTvJYSeQO0WTp8pOPkYQWw+SpdNzxpgsCJk3SZ4sqaGI7LI B6c4csBjWlAs9hyEhJPQfZ8xbS4FPRg= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Sender:Content-Transfer-Encoding: MIME-Version:Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-Type: Content-ID:Content-Description:In-Reply-To:References; bh=EBkUb0Zod9PMNfEgCDDzkHALc55cp6jjtgA5Pre3tic=; b=4tsWEX2wHYGMaDcp38dowwnbkY siqhLhl1H0IrtLIwoKDNc+MYS9LC7kcNE/5IvFDhXXFFRRK/bkDPGWoi7CbhCYZYVPiSzxiCJU84y s6oMkHrHMLYyTmjCjfuOONBN4sc/F6MFjzyZBg9sYpobJ/DbK2oW0EAAK6g8uJGr9nW+4G7tj9KXB GilaFrcZkkCykbjXLLI1cJh89Lz2ESHDIgQDsPnLvVzMKtT25DxgA/rKfn+iBvzenUl427Jp/nqSG xJuwUMO+RMK3DXoBFWKWyRffIWBUtpGq8VgkMDtOR2w5Sfu3CfSjOIcdvsLLQPzq+Z+iAUHT/RfOH 3MAM7X3A==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1sMchZ-00000008hnT-2iFu; Thu, 27 Jun 2024 00:09:25 +0000 From: Luis Chamberlain To: p.raghav@samsung.com, hare@suse.de, kbusch@kernel.org, david@fromorbit.com, neilb@suse.de Cc: mcgrof@kernel.org, gost.dev@samsung.com, linux-block@vger.kernel.org, linux-mm@kvack.org, patches@lists.linux.dev Subject: [RFC] swapfile: disable swapon for bs > ps devices Date: Wed, 26 Jun 2024 17:09:23 -0700 Message-ID: <20240627000924.2074949-1-mcgrof@kernel.org> X-Mailer: git-send-email 2.44.0 MIME-Version: 1.0 X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: 13EE44000B X-Stat-Signature: 6jag34rmk4cjrer4y8n6zeka1aq9tz3p X-Rspam-User: X-HE-Tag: 1719446968-270015 X-HE-Meta: U2FsdGVkX1+fW8YNq/auDwjtgFF7AZPe20RULfvztqS/kH5sXjeHy5M3Dlg/UxQKRcgXKckdv+znCwWq+q+XTA0vxicmDFJ1e7y2afAhABiMMfE4ToCB3fIWBTke2CSXlEAps1ol+GSVfmu/wDFqP0w2suTkr7hRs5eFmH7Te7WXoMrnEi0syJgbuTpegGw0q6+uEvk3fuWL4kJAu9ntxpITNHCACzoXzuLehuDX40UCErlTzSoOzazuBFb6AC+ZjixhX//PSVYHy4gTJ40N417bPGf6+FSuuyiQVumxWQuUfCAxsKQZQz7L3MnUOa4y1P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k4duiSu+LaC0ceHZdnHqIQ1sfHtvmqsKqXTf46P0zvaAXz74jYvrwM4fDsHQdADwHbZCDvC6vj7U1JYR7w= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Devices which have a requirement for bs > ps cannot be supported for swap as swap still needs work. Once the block device cache sets the min order for block devices [0] we need this stop gap otherwise all swap operations are rejected. [0] https://lore.kernel.org/all/20240510102906.51844-6-hare@kernel.org/T/#md09501306c649dd84db0a711f9359570c17a197f Signed-off-by: Luis Chamberlain --- This is super *way* forward looking after LBS patches and once we square away how to support things on the block device cache. Only then does it make sense to start to consider this. But this is just a stop gap. But if you think about it, in practice since we are going forward with a world where we have AWUPF >= NPWG to enable the physical_block_size to be >= NPWG, the corner case we want to help users *try* to avoid is to enable swap not when the LBA format is > PAGE_SIZE (although for sport we can support that) but when the NPWG > PAGE_SIZE. So we'd warn about that until swap gets a facelift. That is 4k writes will work for devices with 4k LBA format for example but NPWG = 16k, they would work with a RMW penalty, just as RMWs today happen with drives formatted with 512 LBA format and today's default world of 4k IU. As it turns out we have no topology information for the IU today. It used to be that physical_block_size used to have a language about RMW. During the 2024 LSFMM thread about Large Block for IO that Hannes proposed we reviewed this discrepancy [1] but we seemed to conclude then that no changes are required. I'm starting to think that exposing the IU might make sense now. The below would not capture the case of the IU > PAGE_SIZE, in theory that should work but then its just RMWs, but users likely should be informed it is stupid for them to do that. The other more important use case would be for STATX_DIOALIGN for the dio_offset_align. That seems incorrect today even for existing drives with 4k IU and 512 LBA format. Thoughts? [1] https://lore.kernel.org/all/ZekfZdchUnRZoebo@bombadil.infradead.org/ mm/swapfile.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mm/swapfile.c b/mm/swapfile.c index 2f5203aa2d2c..9ff168760bc2 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c @@ -3153,6 +3153,11 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags) goto bad_swap_unlock_inode; } + if (mapping_min_folio_order(mapping) > 0) { + error = -EINVAL; + goto bad_swap_unlock_inode; + } + /* * Read the swap header. */