From patchwork Thu Mar 9 23:05:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 13168523 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 B646AC61DA4 for ; Thu, 9 Mar 2023 23:05:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 22BAC280001; Thu, 9 Mar 2023 18:05:56 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1DC136B0074; Thu, 9 Mar 2023 18:05:56 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0CAEC280001; Thu, 9 Mar 2023 18:05:56 -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 F10996B0072 for ; Thu, 9 Mar 2023 18:05:55 -0500 (EST) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id C13A51A0282 for ; Thu, 9 Mar 2023 23:05:55 +0000 (UTC) X-FDA: 80550894270.02.EF3A786 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf16.hostedemail.com (Postfix) with ESMTP id 232E9180017 for ; Thu, 9 Mar 2023 23:05:53 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=seeJm9gY; 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=1678403154; 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=Mj38/Shbs9ZyLGljvL78FJsMrZNw4adJNB7STaV6cuA=; b=JsLkuU4htuZvSZO6Ofbl6UdJ+x7uIhjf/KaMn2RUHE5kVAlNitmSVNgvdlat1yfh5VkihS Un0GAWovr5efC7VGduKy8GR5lK675/Es4nI9DHIdZygHNbgCQ9TtGugX42Fuj4EM1jc4w1 sUcen4Qc2sWG019ooc2W/DJfKiqSQ5w= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=seeJm9gY; 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=1678403154; a=rsa-sha256; cv=none; b=xVhcCimLbsWiKMbnH4XozTb6yrZpqxx05MpVmCR+WMw6Di5f2liMIAjHC1fVTrifHSDS+C mG5IK1WswjL+Sr4vQA5JOdNLXU3sHxkd7eIEU6MZNRftIbem/CaGpJ8kL355yuBcgbssiN p04EU6OXG0l6xOwKgsL7XJjlWo+atl8= 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=Mj38/Shbs9ZyLGljvL78FJsMrZNw4adJNB7STaV6cuA=; b=seeJm9gYP9E41NpNLIQfn02A+C oxlZ3k6wzYiLUH1KFiSb05cnPDxxE85TUCsL05PdvvOaU6QIuFDUpzxwIZeM5WsxwhAmZzqgZSSl7 8hBYfYuPOrxwUcjZKpqMjt3Nb6f22NzLkFsgK7K/Y5Lb/XJs0ZAhpfXLhj0DRTUwjaOTXI8FGUT5d 44OtbSzlkiJoESExutB36lEeI9dejYMgU7S7R7ApLodCoJtM4HPACPX51Ftk7Pyfct5xSDZ0+nutl pXExNQXMnX+lTj1Bareamc66niruXfSdjnmbxhqrUnXtYCLtmkZtYwcGSf+KatBCDrZ3pe1ZlEhyX pd/xldcA==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1paPKW-00CIRU-5W; Thu, 09 Mar 2023 23:05:48 +0000 From: Luis Chamberlain To: hughd@google.com, akpm@linux-foundation.org, willy@infradead.org, brauner@kernel.org Cc: linux-mm@kvack.org, p.raghav@samsung.com, da.gomez@samsung.com, a.manzanares@samsung.com, dave@stgolabs.net, yosryahmed@google.com, keescook@chromium.org, mcgrof@kernel.org, patches@lists.linux.dev, linux-kernel@vger.kernel.org, David Hildenbrand Subject: [PATCH v2 2/6] shmem: set shmem_writepage() variables early Date: Thu, 9 Mar 2023 15:05:41 -0800 Message-Id: <20230309230545.2930737-3-mcgrof@kernel.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230309230545.2930737-1-mcgrof@kernel.org> References: <20230309230545.2930737-1-mcgrof@kernel.org> MIME-Version: 1.0 X-Stat-Signature: wfpf36nsbnukbabzenaxe49xd6cbmx81 X-Rspam-User: X-Rspamd-Queue-Id: 232E9180017 X-Rspamd-Server: rspam06 X-HE-Tag: 1678403153-257682 X-HE-Meta: U2FsdGVkX196tijMgjnFcfM2XhUfUe25DU3guq79yqA1eaUTb1JaWVgzm6sEnLNeWY/quIfpP+5jcP53PLEsyR5u5N2j1BmTowhy+0c57d4JMovwpVo4YFCaP751fbrJBXU8YWpHE2LO0iqs+7/TafKjNz6ZTKEItVn0Eav7SmPe5TAVXbSmV14VOrT3vtk/e2PWXBd+4L372YjWKWBREbGV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vpF9o+6SjvxlU+4hRwqt3hkgpYBFTztqiPKDxLNV+v4ODLhf/+dO8jMTs8cbg5r0Nq8KF9oPxzi+OYUO3FqYQ70c1M7fSBd1m0WZIIRnEQ+heYwdc/obIJ33sNy4VdO6ofuQewk5n56N/7JmRuNH2ERldFhEDISLw2DeYAXtuVT/dGeE= 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. Acked-by: David Hildenbrand Reviewed-by: Christian Brauner 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 7fff1a3af092..2b9ff585a553 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -1334,9 +1334,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; @@ -1354,10 +1354,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)