From patchwork Sun Aug 25 22:42:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 13776935 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 AD44CC5320E for ; Sun, 25 Aug 2024 22:42:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2F2238D0034; Sun, 25 Aug 2024 18:42:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2A13F8D001C; Sun, 25 Aug 2024 18:42:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1904A8D0034; Sun, 25 Aug 2024 18:42:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id ED6268D001C for ; Sun, 25 Aug 2024 18:42:50 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 663D114092D for ; Sun, 25 Aug 2024 22:42:50 +0000 (UTC) X-FDA: 82492244100.21.4EE3037 Received: from mail-pf1-f171.google.com (mail-pf1-f171.google.com [209.85.210.171]) by imf19.hostedemail.com (Postfix) with ESMTP id B45361A0009 for ; Sun, 25 Aug 2024 22:42:48 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=VG578hFe; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf19.hostedemail.com: domain of hughd@google.com designates 209.85.210.171 as permitted sender) smtp.mailfrom=hughd@google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724625706; a=rsa-sha256; cv=none; b=xol5Gyde0NaW244VP9WhTVqe4bciL/7mqQuAkHnQZaptgEV6CDaJAikmEgplf1KgqGtMxm LA2rtLcjJArsmYfZf6+8oc0u0k+06smRnoXsFimBHye+jUwEeRUcNCgcZerUWi78Obzjzh ybPF6W3hMnWHdHHS6b1VdsoRWFU4ilg= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=VG578hFe; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf19.hostedemail.com: domain of hughd@google.com designates 209.85.210.171 as permitted sender) smtp.mailfrom=hughd@google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1724625706; 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:in-reply-to: references:dkim-signature; bh=0rBvHDWVfkdQt9ZpCo+KYmKH0Q02QEi1n33koP6jBAs=; b=eB+51pNTelg53lP4vZRJHSSXx5u3NwwjGneVR+ZOiEaYIScvYNMOYThVOzL8N0cODAJrVU gCIFGxrMDt0LQ4AODpbXESs8E5GCgws4EnzwvEEcy3plQubjQMtEQWh0gaTrpdUCf2FGgf HRlzu4Ta+YKGPe738EJ4a0seHbcEGgQ= Received: by mail-pf1-f171.google.com with SMTP id d2e1a72fcca58-7143ae1b48fso1974834b3a.1 for ; Sun, 25 Aug 2024 15:42:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1724625767; x=1725230567; darn=kvack.org; h=mime-version:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to; bh=0rBvHDWVfkdQt9ZpCo+KYmKH0Q02QEi1n33koP6jBAs=; b=VG578hFeNpoFDhmTdkOrTi56llF2oNn0YsOF0/gADdZHWrMSKs4NURs/OyzzSUrMx9 1hRKr4VmunWtukEKJtSFT8yffI2hqTceiAm3hf2lK6+V49Mw+ydj8KqRV/TRakNs3nCE Nx0ZDOxYXUOA+DX5I7w+7ckO8fD6ZzEJCIv2kivf1QLM60+STwFQI0qXIVaHjRFl9nnk 5UvpiHIS3JIzqvmQ+bBqv/pz6W3BIJvEgSblE0JPA1DV/VfHEfLSkPjYrmCSl7t1TV5l UU3iVNiYDVG+7nV+00Cd0MyFIxgk4UhAC9gZhENOPU3fEEPLAuLCnX9daR6Jf5RJJRWw shMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724625767; x=1725230567; h=mime-version:message-id:subject:cc:to:from:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=0rBvHDWVfkdQt9ZpCo+KYmKH0Q02QEi1n33koP6jBAs=; b=Zh175iszYglf1jALzfam84BjYiizULJsjCdUN32/zIrqQPiG0pspNvgGAjBEBTdHc5 9PyG5Twqh432h/GV8roMNGRaD5+19ulsruUhN5zVUTlwIfvjPZU1vjwp/QJ81c+UQOfr 8eCHGlswWZjZN74FzIAYxQB4xHR3Kz82KKDvy1sq6FD3VmAGlayr3BZV+huM03PLWKeh TlflFqNs/NSEW0dLJdTew5Xywkd21IZLTtCi55g5ka9frxrgYO203N34g0z2I92I0zoN jdAZ4fpI6Ti+LvjTlOmpxJ1QthK4LcQLBIZFvSrLD6GTYvJEvAOJiQZ0/oI8EcqCIXgq q/XA== X-Forwarded-Encrypted: i=1; AJvYcCUmh7KxOL5zwVtTwGgLjW4ky++Vj6kWT+I540eslxna+vORL7b9v5E5eN2FA3/UXwr+Gw7weejP3g==@kvack.org X-Gm-Message-State: AOJu0YwwzHO8JfJRARIx+24KH6lmL8r2QIJx1XFtAQvZnX8tNTu7KDJP Zk87IHNN6p0tCWeg08DdTPZ0s9N67ZbG2dMN4YGi30ZdXk3EPff4+EctC2F1ag== X-Google-Smtp-Source: AGHT+IHJwZpY6lEHZ/ct9FFk8qm5lFxEP/XcocOCIhB7oCMa+mmuyaBprncVdk8yfSnsFc5hznBgYA== X-Received: by 2002:a05:6a20:9e4d:b0:1ca:db51:85df with SMTP id adf61e73a8af0-1cc8b419fe7mr8650270637.8.1724625767042; Sun, 25 Aug 2024 15:42:47 -0700 (PDT) Received: from darker.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2d613b2048fsm8379942a91.54.2024.08.25.15.42.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Aug 2024 15:42:46 -0700 (PDT) Date: Sun, 25 Aug 2024 15:42:45 -0700 (PDT) From: Hugh Dickins To: Andrew Morton cc: "Kirill A. Shutemov" , Baolin Wang , Hugh Dickins , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH] mm: shmem: fix minor off-by-one in shrinkable calculation Message-ID: MIME-Version: 1.0 X-Rspamd-Queue-Id: B45361A0009 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: cajqqzufetg6fq9rioyzgym4s99bs5xe X-HE-Tag: 1724625768-831025 X-HE-Meta: U2FsdGVkX1+L0e20phkunRLTV/AoQTjJgZekO3Z0ePxwK5OBrtcz3ZC2CoVDIZ0i8iQac2K9HNtM73gzZpflUbCt5OEpO+V9rUKZ1SULZaQ+YtD/8zsZJVQuH2qS+LQXIvPbwFxgphbVQfNQcOk/apIG5CkRiioUdmfCoY8PgrdS/vJ1SZ6dk9fPWkSLmu5hBjBok6NCxLq7L234ckzUc1zkxMrH2Ygtpx0T5f5p+MAzcJ5HlHMHLQN6ykfuBM/kwzfj0EgIG7bghXPXleh3zcEhW580bxzhV355pnmf/ZaAL4ubslhDHE/v6WcMy6z2RrmcfviDIs1h4n8lGUjRTdSri8Xc8sGQvntoTYGOO8AMnbRN/1X6yTKEMSq+MPIa7a0MN0wLotT0nxeJ9b1LECBwQVyxVPyJ9wnB7xSjgPweRTAR1UeAKAo5uNlPTc3XDUllUoYHCcYYAONp2vYR8Po+YRuPZgcl85KS9q4HFhLM+EdW6f3bABH42KOibrYIJcw6usvacNmhYb/swY+o20N7ww+O+ikD6yoo7327ffQKyDiMJziIO5xl55JqdpwXP5NDNudUnDLgfIgpaPN8gdr5DYTdNi5Du9WEX+cH+SBkBoNcLYZzvZrX2cPLE0qcO3yTq4XxgQPr6hm6EKUdFty1k3sKlcuEgksCqg+1mIVKs02BxO4viJjp+0vpw2hl/mR2fYuc+bCwZew1WuTbHyQzDXfc/pzlYOsN9n/S5EB0x3ANgr8BbZVQtiBR/nyVUS8i+nCGx6crPIpfDryJPU6pw8nt1/TRmnkJw60IS041ZH50jGPBJ1V1GWOghNhXBFpSNv/zMuUZ41qKWLkdXa3dVatepG5jbYP9QHq98wwyiSgDIIxjS1tLvpbYHx2pOyKGn2YzsDKGih3g1+XZSr9qLbZf6Qq8r/mY9OZyuy7+uvXe1uHQHH91hJg4df7XyKF9Ifz1FslyfiKRFVe NQbg6bwz nRAqjFgzp6uefURllTrDndk+yfYB5bQPiXDeJyemEzWuaxi0EsMsB5QotW5ou9EFyZ+UVxoYqX1uyFtb6m+3/sHvJ0XpKMp1pf2FQEhKIkDfHBTvva9jCLcenNqAD6KSF8mWNs4lHs15USEo0qOlwR6I3/yPhLA7yQ4sUaR3zK0UwvvZJc8Ini6LFwcdEduhj9f1nbjrcV8OXo5nWNsgqIrXWfSHRwToRUDx8tWP9Ccsp6uzBXzX6TpJyFY7X40gsNeYxhTLg+F1hY46UITbCACJqvAG4GqSAX1KRbdrcFhkX4gyWKahyE3UncMJwFCh5aDItQEY3yKEPoyL76/A0wtxwoH+jkEBAKJ6Fva4pr9cCJHg= 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: There has been a long-standing and very minor off-by-one, where shmem_get_folio_gfp() decides if a large folio extends beyond i_size far enough to leave a page or more for freeing later under pressure. This is not something needed for stable: but it will be proportionately more significant as support for smaller large folios is added, and is best fixed before duplicating the check in other places. Fixes: 779750d20b93 ("shmem: split huge pages beyond i_size under memory pressure") Signed-off-by: Hugh Dickins Reviewed-by: David Hildenbrand Reviewed-by: Baolin Wang --- mm/shmem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/shmem.c b/mm/shmem.c index 85e3bd3e709e..37c300f69baf 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -2326,7 +2326,7 @@ static int shmem_get_folio_gfp(struct inode *inode, pgoff_t index, alloced = true; if (folio_test_large(folio) && DIV_ROUND_UP(i_size_read(inode), PAGE_SIZE) < - folio_next_index(folio) - 1) { + folio_next_index(folio)) { struct shmem_sb_info *sbinfo = SHMEM_SB(inode->i_sb); struct shmem_inode_info *info = SHMEM_I(inode); /*