From patchwork Fri Apr 21 21:43:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 13220709 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 14FC7C77B7E for ; Fri, 21 Apr 2023 21:44:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E63556B0078; Fri, 21 Apr 2023 17:44:20 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AB9D46B0071; Fri, 21 Apr 2023 17:44:20 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8709A6B0075; Fri, 21 Apr 2023 17:44:20 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 494976B0075 for ; Fri, 21 Apr 2023 17:44:20 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 0FCC0C0974 for ; Fri, 21 Apr 2023 21:44:20 +0000 (UTC) X-FDA: 80706727080.24.07D4C76 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf04.hostedemail.com (Postfix) with ESMTP id 10CC54001A for ; Fri, 21 Apr 2023 21:44:17 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=DnGs3ejE; spf=none (imf04.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=1682113458; 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:in-reply-to:references:references:dkim-signature; bh=HAZkfNRruAgARTe618ACsQ6wCYRRSd9EZooPKA+qgbw=; b=pEP6lsoSagu8AX4f06EOnHGDr54g6t+zBL4AhfBj+llfd+2h95C20Z45fnapG0Ydg7wspJ XvVfOa33mCSbS5NOBY5Pr0MJ88xpLnoFmqxGSZUdCM80rIkvYWixUGE2qocMluhu/JwgDq o7ZvUaaPCCin/xplafw5yLQmbD+0wCI= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=DnGs3ejE; spf=none (imf04.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=1682113458; a=rsa-sha256; cv=none; b=7H4Zw9AsaGAnxS/V9DSNiirzrlYcRx2AcWvT1mCoBRJ0iG2jcuGw/Bzo5Sk8cuZa9Vdfi3 0Dx3Z507aVsPOYjmC7nd1Aj4c+hdPKP1kc7AVPa0jwe+VcGi9eAZ8aEu+Kehu1oVBtfjOh VKWWLshflIy4jKfYudZdd1jKrxRS+jE= 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:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description; bh=HAZkfNRruAgARTe618ACsQ6wCYRRSd9EZooPKA+qgbw=; b=DnGs3ejEo/+K910m27ugy2zmJh qb5mcLlEfR2wdQNE/p1//CuFDbtuczZKd7j27Gu+GCzFIVBmDmCr5B7yxLhtPcDngNB4k80THHDuR w2DMyrzuDU9msgM7Zy+oghoVKusNkUcBRoJC/pAS7Cc8RxdQEaVjJ+Bd2tc6Z6+C7gpfmYibKo708 Vi5Tb7IXkNa4kvn4N3d3BddjBa5cCKcG9E33SvWZ4GkM7ZwxcmNuAPg77qD1HGAf/ilG221q1rmJ5 9ejkkgHgonznxoi20BOMaCnyIcdksGRblL0lJg1XSWnZUtylSqq5ykxsRsCRkUyoDucbBY5Vd4B0h p73Bmwcw==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.96 #2 (Red Hat Linux)) id 1ppyY1-00Btoi-1l; Fri, 21 Apr 2023 21:44:05 +0000 From: Luis Chamberlain To: hughd@google.com, akpm@linux-foundation.org, willy@infradead.org, brauner@kernel.org, djwong@kernel.org Cc: p.raghav@samsung.com, da.gomez@samsung.com, a.manzanares@samsung.com, dave@stgolabs.net, yosryahmed@google.com, keescook@chromium.org, hare@suse.de, kbusch@kernel.org, mcgrof@kernel.org, patches@lists.linux.dev, linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [RFC 1/8] shmem: replace BLOCKS_PER_PAGE with PAGE_SECTORS Date: Fri, 21 Apr 2023 14:43:53 -0700 Message-Id: <20230421214400.2836131-2-mcgrof@kernel.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230421214400.2836131-1-mcgrof@kernel.org> References: <20230421214400.2836131-1-mcgrof@kernel.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam03 X-Stat-Signature: syu3x8g99p3ouo4pisauggh8akbj91ne X-Rspamd-Queue-Id: 10CC54001A X-HE-Tag: 1682113457-994454 X-HE-Meta: U2FsdGVkX18zh4+URRC1dh1Wrb8jr3aPCrAvwxzvYrqnbbHjJ3PEEWsnbpmoNVmU5wRHCkqms4xIwC7UXUt3hdk/oGYbqZ2zeY3gR6343a8xg9Ytvyw8bNsU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+fHZd+sDFLZOMmK5jmGJImZJysnlaeVzdY0hMXvuVpAbWFMs1x1hacAQSwHnJy970ym5C4vd0HKSVJvX4M8PDCFsLcvum7CNTsryhf2e85WPTMuchLaqXCYqL+yaFnoC7zr0xFTPG+HGxNKvJhP/sLmslYIIeg+QWrlShRQZOVFEsrHdWgegwJbYZtBCXOQGKCXru1e5xQGd2gg28FUVFXruOgVK4fQ86QrvAv7bT+PStKnvVlte0vPXtHCVJg 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: Instead of having our own macro use the generic PAGE_SECTORS. It also makes it clearer what we are trying to compute here on the inode->i_blocks. We get the inode size by as define din __inode_get_bytes() by: (inode->i_blocks << SECTOR_SHIFT) + inode->i_bytes This produces no functional changes. Signed-off-by: Luis Chamberlain --- mm/shmem.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/mm/shmem.c b/mm/shmem.c index b5d102a2a766..5bf92d571092 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -86,7 +86,6 @@ static struct vfsmount *shm_mnt; #include "internal.h" -#define BLOCKS_PER_PAGE (PAGE_SIZE/512) #define VM_ACCT(size) (PAGE_ALIGN(size) >> PAGE_SHIFT) /* Pretend that each entry is of this size in directory's i_size */ @@ -363,7 +362,7 @@ static void shmem_recalc_inode(struct inode *inode) freed = info->alloced - info->swapped - inode->i_mapping->nrpages; if (freed > 0) { info->alloced -= freed; - inode->i_blocks -= freed * BLOCKS_PER_PAGE; + inode->i_blocks -= freed * PAGE_SECTORS; shmem_inode_unacct_blocks(inode, freed); } } @@ -381,7 +380,7 @@ bool shmem_charge(struct inode *inode, long pages) spin_lock_irqsave(&info->lock, flags); info->alloced += pages; - inode->i_blocks += pages * BLOCKS_PER_PAGE; + inode->i_blocks += pages * PAGE_SECTORS; shmem_recalc_inode(inode); spin_unlock_irqrestore(&info->lock, flags); @@ -397,7 +396,7 @@ void shmem_uncharge(struct inode *inode, long pages) spin_lock_irqsave(&info->lock, flags); info->alloced -= pages; - inode->i_blocks -= pages * BLOCKS_PER_PAGE; + inode->i_blocks -= pages * PAGE_SECTORS; shmem_recalc_inode(inode); spin_unlock_irqrestore(&info->lock, flags); @@ -2002,7 +2001,7 @@ static int shmem_get_folio_gfp(struct inode *inode, pgoff_t index, spin_lock_irq(&info->lock); info->alloced += folio_nr_pages(folio); - inode->i_blocks += (blkcnt_t)BLOCKS_PER_PAGE << folio_order(folio); + inode->i_blocks += (blkcnt_t) PAGE_SECTORS << folio_order(folio); shmem_recalc_inode(inode); spin_unlock_irq(&info->lock); alloced = true; @@ -2659,7 +2658,7 @@ int shmem_mfill_atomic_pte(pmd_t *dst_pmd, spin_lock_irq(&info->lock); info->alloced++; - inode->i_blocks += BLOCKS_PER_PAGE; + inode->i_blocks += PAGE_SECTORS; shmem_recalc_inode(inode); spin_unlock_irq(&info->lock);