From patchwork Thu Feb 23 02:44:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 13149790 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 1E707C64EC7 for ; Thu, 23 Feb 2023 02:44:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 172F56B0075; Wed, 22 Feb 2023 21:44:22 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 000A76B007D; Wed, 22 Feb 2023 21:44:21 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CEEC86B0078; Wed, 22 Feb 2023 21:44:21 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id B78ED6B0075 for ; Wed, 22 Feb 2023 21:44:21 -0500 (EST) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 8D7C4160EC6 for ; Thu, 23 Feb 2023 02:44:21 +0000 (UTC) X-FDA: 80497012722.03.609A782 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf16.hostedemail.com (Postfix) with ESMTP id 65D77180002 for ; Thu, 23 Feb 2023 02:44:19 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=K56am7J4; spf=none (imf16.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=1677120260; a=rsa-sha256; cv=none; b=1/REeSp6dEnAIe+8y1hfVTbQPSIIr7nCGcIPaNBlV022EHDcrVg6NLpV40rvDg0X0og8KG Q6Ce5TkC89KOM6JrYJVESluKHsEYfsCVUwPaQqSpnnwfGHudefY8lFegbOoTqcVWfS8/DO vnMiRFNZxVnxJvstyfcMj9OTiyuz5+E= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=K56am7J4; spf=none (imf16.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=1677120260; 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=Zf/VP5ikCHj8OLL6rer4hxqpVXK1ALaeitWH3YJJWGw=; b=6UhmnUHOMf/J4TXpyQQF0EtNIuerKIJGJm9dZazD88vDe0Izj3S7V0c2eiSe3jBLN6hNcS RAds2QzikL9BkCZUuy75P5vizhwnZnXzamViCAaNQknvHt6GECis2aqd50csJdjRZgRZtc gOJ+aRnSZIIOCsCuG9M4tswonU9u+gY= 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 X-Rspam-User: X-Rspamd-Queue-Id: 65D77180002 X-Rspamd-Server: rspam01 X-Stat-Signature: niw71h9aaus64xi7c877thek4ih798qe X-HE-Tag: 1677120259-21186 X-HE-Meta: U2FsdGVkX1832ok5TjpX0EvlQQigKBIK8sUzEIQLBk5xp3uvqbudBMJ57RsZHqjJ6lmo33tf2JEp9ob4SGpszAFc3O1fCRHmJ6T0ZDHVqHQHjSkaV0yHfelaXfEH5VE299GogJgOIGZTF5NNUNz7sAx/6dva4L+5VmPDHAlF8lbJx38C5AD8Dk0cHbgQIAYemGye5uiM5Stdn4FNiQrNGECvq0ZG3bzYrsTqD8lZqVmdAe7w0KyyCTQ7auU28pnogCHm53yu0dD5ruMy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Fjt5taZb04i5pXJcdSDkReDVrUhDwY4ytOiFi0/5UTUD39ZyO+Q4RK6/0cssjFp7QDnYQpMxkvoHwq5K8Gt2O4B6Hw56stpsiDVwAxgA1UycpYw= 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: 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 *wbc) { struct folio *folio = page_folio(page); - struct shmem_inode_info *info; - struct address_space *mapping; - struct inode *inode; + struct address_space *mapping = folio->mapping; + struct inode *inode = mapping->host; + struct shmem_inode_info *info = SHMEM_I(inode); swp_entry_t swap; pgoff_t index; @@ -1351,10 +1351,7 @@ static int shmem_writepage(struct page *page, struct writeback_control *wbc) folio_clear_dirty(folio); } - mapping = folio->mapping; index = folio->index; - inode = mapping->host; - info = SHMEM_I(inode); if (info->flags & VM_LOCKED) goto redirty; if (!total_swap_pages)