From nobody Thu Sep 11 02:01:30 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 48B65C636D6 for ; Thu, 23 Feb 2023 02:44:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233068AbjBWCok (ORCPT ); Wed, 22 Feb 2023 21:44:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57222 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233082AbjBWCo2 (ORCPT ); Wed, 22 Feb 2023 21:44:28 -0500 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E98226CEC for ; Wed, 22 Feb 2023 18:44:23 -0800 (PST) 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=Zf/VP5ikCHj8OLL6rer4hxqpVXK1ALaeitWH3YJJWGw=; b=K56am7J4RdGNuU6o8W0jdqS0ki klpCVr4uB8PIfFhNoUaw6mxyic+kMZCAItqPxG3BiXoGQRqZaOocgPrH8mWw6CjcKST0X8JSSiCeA QpOTOeoXX9qjWWrb0lLLZffp5U5PkWf0kMvODDM27SmUhugLUSV5VWCWJf97zZ+rLq0Ow8isJpKAD TMwO2rPqOxnEnU+FpRlGvZZwYXSjTdYixOT0+ynh1x0slK5e1rlLbrccAEbpoTtEnfYzvg4bZcNGx D9TolFbzyTqguOlMSvw5Qzrs2hGcv8k/0Y2R3MBKDoLHYT3zuIuEb9r6VtYKNR7qareuSz5A8lT/9 XlQqeXew==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1pV1ah-00EmNA-7d; Thu, 23 Feb 2023 02:44:15 +0000 From: Luis Chamberlain To: hughd@google.com, akpm@linux-foundation.org, willy@infradead.org Cc: linux-mm@kvack.org, p.raghav@samsung.com, dave@stgolabs.net, a.manzanares@samsung.com, yosryahmed@google.com, mcgrof@kernel.org, linux-kernel@vger.kernel.org Subject: [RFC v2 2/5] shmem: set shmem_writepage() variables early Date: Wed, 22 Feb 2023 18:44:09 -0800 Message-Id: <20230223024412.3522465-3-mcgrof@kernel.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230223024412.3522465-1-mcgrof@kernel.org> References: <20230223024412.3522465-1-mcgrof@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: Luis Chamberlain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" shmem_writepage() sets up variables typically used *after* a possible huge page split. However even if that does happen the address space mapping should not change, and the inode does not change either. So it should be safe to set that from the very beginning. This commit makes no functional changes. Signed-off-by: Luis Chamberlain --- mm/shmem.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/mm/shmem.c b/mm/shmem.c index b3ad619328bf..1269482d0a5c 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -1331,9 +1331,9 @@ int shmem_unuse(unsigned int type) static int shmem_writepage(struct page *page, struct writeback_control *wb= c) { struct folio *folio =3D page_folio(page); - struct shmem_inode_info *info; - struct address_space *mapping; - struct inode *inode; + struct address_space *mapping =3D folio->mapping; + struct inode *inode =3D mapping->host; + struct shmem_inode_info *info =3D SHMEM_I(inode); swp_entry_t swap; pgoff_t index; =20 @@ -1351,10 +1351,7 @@ static int shmem_writepage(struct page *page, struct= writeback_control *wbc) folio_clear_dirty(folio); } =20 - mapping =3D folio->mapping; index =3D folio->index; - inode =3D mapping->host; - info =3D SHMEM_I(inode); if (info->flags & VM_LOCKED) goto redirty; if (!total_swap_pages) --=20 2.39.1