From patchwork Thu Jan 11 18:12:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13517688 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 63D91C4725D for ; Thu, 11 Jan 2024 18:12:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id ECF086B009F; Thu, 11 Jan 2024 13:12:36 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E7D7D6B00A0; Thu, 11 Jan 2024 13:12:36 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D1E7F6B00A1; Thu, 11 Jan 2024 13:12:36 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id BF7C66B009F for ; Thu, 11 Jan 2024 13:12:36 -0500 (EST) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 668B680CDB for ; Thu, 11 Jan 2024 18:12:36 +0000 (UTC) X-FDA: 81667825512.13.E9180EE Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf15.hostedemail.com (Postfix) with ESMTP id BD63CA0029 for ; Thu, 11 Jan 2024 18:12:34 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=Dly8SJF3; dmarc=none; spf=none (imf15.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1704996754; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=AS+uT7usg/s9J/TDR9k6OcZVDPC0GngCIBakXKVBtYw=; b=5wY0wbV5Pk1I+5Rtr9LJnpJVs3rk0TZABpfq7ugj8y44j42wG1bB0O/Y8wifuUI2MJElQc VDTKrM+vaJkw9fLS87ZF08QHXT8iEyTZzkeXd6GpBfjNWvmsKCVwl1aexNlXlHjNZ0oIsE YUrOaxVwcuHXsFyoi08FI2n+cBonvxo= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=Dly8SJF3; dmarc=none; spf=none (imf15.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1704996754; a=rsa-sha256; cv=none; b=fUjfUh6ZkXFEQNki9nYPhwnO0jBAlMMJizG7MbwzGIhVZCfEO7X9urS9qkR1XPXBaDBGHv eKl6CXNpHaej2IYV2vUtsNwbjaEL0TXkszLQBv9hxeDe9XLi8X+YTDLh5AIxGHvO/HtM// FeVuyfV0X+b3qQRWPNHEfLoWp+z4bA0= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=AS+uT7usg/s9J/TDR9k6OcZVDPC0GngCIBakXKVBtYw=; b=Dly8SJF3pkBydTQIAvm2nT5dA4 9Aq4dmuKHgGbPIE4kTwz6uoNMZl+DHU7IMGFPey88/uA1ij73+5/j0Ui5a43nr65m8kLyZ1LM7acB R2b7rD/EoU7FfPOShDM472o4/xdGeLbM/29Hi/BZczIe5rnh3n4vU9ygevgY+uC6bZ0/B5iDq3Wya QQmnVSFYLa+KRlGpgrVYbhkHDTZTnCp3ufFfm1yxTq68OiFZqYdwWuVUKxhpAJ6ve9B7heg0ghmhd e3RIXQkaboHVKAyfuR+awVljhPAuXzoPlt6d/Z6GZC0ZScBFhO+Qf2RNxscxDgMzHwx0pUHD+tqjw wF+oOoTg==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1rNzXR-00EWr4-NM; Thu, 11 Jan 2024 18:12:21 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , Johannes Weiner , Michal Hocko , Roman Gushchin , Shakeel Butt , Muchun Song , cgroups@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 4/4] memcg: Use a folio in get_mctgt_type_thp Date: Thu, 11 Jan 2024 18:12:19 +0000 Message-Id: <20240111181219.3462852-5-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20240111181219.3462852-1-willy@infradead.org> References: <20240111181219.3462852-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: BD63CA0029 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: b1575xyxuuyu1yqbaewfrsn946kws6mr X-HE-Tag: 1704996754-148954 X-HE-Meta: U2FsdGVkX19uMhzyGjgKfuFc9IdW+dS91ZUcb4DF9L4o/qnk7vbzckiS1v03P114Mu584NZrVLJtuOyHUakem9sULYTU2RoFQNurDTa5O6RcS0FYOAJNRfdldoej7uYILzGZraN0ks71u0Qqkq7NyVLnprhDiT1hs3ZUqiSlHbU90mTJ66RzUFCrI/kX1/gb1OgKY7DnWJSWG9Y1N8qokChp+uWio3ej+UH702WMzhWQsrDZLBTzttlOjoL4NBen57uMVchI9rGZMvw2lkwLNyWZ0x9FZk56ECQcLWeBXLJYC9qcvaMBiYGyAEMZ3KHIqwPdEmVQBCWUbxDdgi0JjknPKcdmJd8h0a83zmHmh4hZ5Mj84b95UeUd/O9b6M0XapngViyWhMQis1dThDY1NWwdeMx2ZaXCCjTEwgEpKJteN2rcMTP5j+fFLIl4B+t7on+35VlPw4jWU7azqSVoAKRncnQq8dlKEYFmoHRMA5UyJo6iHJ79zYH1QB4Hq8mMzoQw4BbZ1MyVhNcomqH2wXagm68bDRQ+yhJtcap0o09ru3iqcsHbZ/jlz2hVeFe5O24Sz49BJ+c8OFQBJChIOdoFMZAvUjWsiDihjM6XLFqvKy6TqiY5U2LdG5ciwbxbQ66gaGI1FEj2Co3WU0BlRqFzY1/saU91juD8awuboXxvfyNBmDeR/JSS54C9vM+e3sAs+NDjr6tAVfNG7KdcNnEp2wRqjOhfsPDb0IYoLcdNcH08aGxmw3CsOa+8163HVuQb1ru+gN9bB1mNKwULrDJeHPK2HLHwTJ/FyboSKfwVesWLDkzrfSPD/zWXIZhYNoUInQHYZIzyQ6Ca6P3oL7tIbLVWke0Njaeqx9EEL1PX5/Ha0fCgcH9reRVKucKOilUuOSg8Qrkw3Be4DTP2SbbMAW52z3PcCjcojPpioULzxooB3fJmW0cpCkeVMJJ39jj7eUrARfYJGK/wZf0 Mfp5IzTG GFrX0uC5bP7mDD11hHmm073xmH5o8UwFBVF8YOEsblBtMMQjXqwAVsEIrFcZF4NzRDsgK/Y0L4zyDYtvsvuKOm024uq0+Pe29f0fUtxTzADgYqU7vIgZkbjYG7Z2J5ckngwpWkk5TSKEntmQ7cxYT32LnshKMjmCpWYIGzCXbCCaCPJawmI1gLGaO/GX04hm59vEM++Hf3iOJgfuhlJhen/fq4yeOiisucCXZ 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: Replace five calls to compound_head() with one. Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Roman Gushchin Reviewed-by: Muchun Song --- mm/memcontrol.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index b6096c34b3e4..935f48c4d399 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -6161,6 +6161,7 @@ static enum mc_target_type get_mctgt_type_thp(struct vm_area_struct *vma, unsigned long addr, pmd_t pmd, union mc_target *target) { struct page *page = NULL; + struct folio *folio; enum mc_target_type ret = MC_TARGET_NONE; if (unlikely(is_swap_pmd(pmd))) { @@ -6170,17 +6171,18 @@ static enum mc_target_type get_mctgt_type_thp(struct vm_area_struct *vma, } page = pmd_page(pmd); VM_BUG_ON_PAGE(!page || !PageHead(page), page); + folio = page_folio(page); if (!(mc.flags & MOVE_ANON)) return ret; - if (page_memcg(page) == mc.from) { + if (folio_memcg(folio) == mc.from) { ret = MC_TARGET_PAGE; if (target) { - get_page(page); - if (!trylock_page(page)) { - put_page(page); + folio_get(folio); + if (!folio_trylock(folio)) { + folio_put(folio); return MC_TARGET_NONE; } - target->folio = page_folio(page); + target->folio = folio; } } return ret;