From patchwork Mon Apr 8 19:42:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13621546 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 F3792CD1292 for ; Mon, 8 Apr 2024 19:42:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 422916B0089; Mon, 8 Apr 2024 15:42:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3D1886B008A; Mon, 8 Apr 2024 15:42:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1AE726B008C; Mon, 8 Apr 2024 15:42:44 -0400 (EDT) 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 EF9E06B0089 for ; Mon, 8 Apr 2024 15:42:43 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id B30AD160167 for ; Mon, 8 Apr 2024 19:42:43 +0000 (UTC) X-FDA: 81987387006.21.D7F98A7 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf08.hostedemail.com (Postfix) with ESMTP id 28C36160014 for ; Mon, 8 Apr 2024 19:42:41 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=izrbCC2d; dmarc=none; spf=none (imf08.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=1712605362; 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=dlGaAuj8W6+fTT3yAvD1acTea9O34uBo7ScibxUX1SA=; b=7mFoFGSKaNxA2Lkgyrv09MV3fnR9Qxz06YMBiQkBt0Shlbbywz4k8ikl0P69tvnpv8lqOZ lX1guJNU4Wa2vwX/D+Rd1vFnwtoDpKfMXiCJLxMFEcQUKDy6jb82mQqtupw0xTdaruCvVr q7DbN021n6W3ppXBLcpxeoOH6KzoRcg= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=izrbCC2d; dmarc=none; spf=none (imf08.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=1712605362; a=rsa-sha256; cv=none; b=geanU70ImAn9piVJK3uIfZRmKMdwOlbibiyYVucDJ8qBtby4VI36uutsA2FSvLnR2JgZhv WXoqIQ65zqtTN0J/xJVJ8fcx6UiIewRV5JyXCCxIIxxT7xaFuQhSdRGg5HI2gZ/s7j0O79 tgiY+j+8QE5u0pkkoE4xaisF9RQliCo= 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=dlGaAuj8W6+fTT3yAvD1acTea9O34uBo7ScibxUX1SA=; b=izrbCC2d+ZrDT9766uHaoSgks2 DyoQWurwpcPgY6Nocj8pSobJtDkVUpP5xbrox93bMm4PsD/aclyGsKsQO2/j5IAi/0Z1D6jgO83AB T8qxHegSqoe/q/bLogjvojVhUuiwpB89GskEUwthwfZ7VzjXdhqIEDqsyFpQjU5mGLcAbT+GcNQU8 zoh7G1RhHC4dSi34WNOZT/q96UvUx04Dfa2JZ8IvL4WehtMq1nbqftRXU//98xMxIm5O6aF742cGA lCw47OakWv4COOQEcQdTnxGVUBLXV8i2QNIBLUFqDJjBgj9VyEaoKJA2WusPE/jXoiXvYbE5oRx2H xDUJRCBA==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rtut1-00000000UqT-2KIC; Mon, 08 Apr 2024 19:42:35 +0000 From: "Matthew Wilcox (Oracle)" To: Miaohe Lin Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org Subject: [PATCH v2 11/11] mm/memory-failure: Pass the folio to collect_procs_ksm() Date: Mon, 8 Apr 2024 20:42:29 +0100 Message-ID: <20240408194232.118537-12-willy@infradead.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240408194232.118537-1-willy@infradead.org> References: <20240408194232.118537-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 28C36160014 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: bhynunbct4krwxzszmp93c374mij8a1r X-HE-Tag: 1712605361-110111 X-HE-Meta: U2FsdGVkX19QvyxTUfO7VSVoAQOvj3UbcEKOyJqPfTuVd1lIcW//k3Fh2AeZI47pUWLlSM1j9TkWyLzRAR0ZiSf+0Th8ZkI2xHE4ed7889+sa8ipoL+pCYuUpiVEpJbnJgH6P/6u3Vg0iBRpoG03vrhh1s/0Nx6QSYYSMQY+nHR+NsbHmU74Z3wMV+vZ1Pn1fhODx7OypuIxHojL09YfEDNNJGit7wgJLjWJbkIY1H1aU0aje8ymbKXtnAp8yTFS5BlyUKHx7afLxkLf3yPm5xPcsM15pb1QSnhTg2DJjxQMKKXz9QEYDP0qDZXi/LVAtgxc/0JDLTw262cWDgTuCv3s/D4DWE7EUP4cP05e0LZheife7OHigLORlseAQO9DgMg9czZUTAwhPQD75NziS7vREVI1XI45EV6y9pk+2SRcyiqu2nse9EDBIKNLPvdRYw5HIfCRajxVndrjR7P0uOfB3dBYQftpNPZxT37+dpV0wf5G2kyrCVkovD36sfgXL2fNB1AMYwtA1cjJpe0xDmBPguoXzwk9HUQz/9Zl1foYzGM28/Kpv3kL1Mo2PrN/bvONw1Y0bINMejio6heZBEfUIq5OHkLAL4SrN6bXqyNKArFcBP3kS5xo8LeC9UM8Oevn3NblaboeJjdj1VgC9ex+emlYelnTN1XUv8VUzQ/M2xz2lzVULyBhsMmqo6YPlGUHvbe52/Ks6AFEmsCBFxQdasL+/ghwt2EEErhJqdfsyODTrHEtc+tCvF7+0MCWJpHtjuTD5INcq4hrNVDhFT+L4u8hNf2SlrDJiVD6YJ8NoTSfBZ4qL1lP9Dau3hs6+7blCybqgWmrYlqQGSAc8PYE4lwhIMuSBgaQIBwNgyQxDxACIP5dMymOSS7cswU1TcW/3deWzkKB/Hg2rG8GgrEZxMPYJi+AMUeJ82J/YlyT8frmfFsgEkF7/QymHbkyKVwKRYZKHgcBRbqLFlJ g0r4moje eHXwVWdY6BfAo0MExXlZYDz4jnfW1PZPJ3InDaWg78bjsmqX+ZLFYE3clm7fcWhplgXUKVMuwmlTO6c0sPxG8Snw2/li1KxYi+BIUwP46CyO04hwP+LoOLskALSPDzhBziUvZ8Shj93l2EJI+qr14HC7flBroTXw0hifIAz4JjqffXjGZFtx6ccKm2EAs9AdtgKNU4ec2Nt3yo94VhHa29mapRbPxxULsmB7M 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: We've already calculated it, so pass it in instead of recalculating it in collect_procs_ksm(). Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Jane Chu --- include/linux/ksm.h | 14 +++----------- mm/ksm.c | 5 ++--- mm/memory-failure.c | 2 +- 3 files changed, 6 insertions(+), 15 deletions(-) diff --git a/include/linux/ksm.h b/include/linux/ksm.h index 358803cfd4d5..52c63a9c5a9c 100644 --- a/include/linux/ksm.h +++ b/include/linux/ksm.h @@ -81,15 +81,9 @@ struct folio *ksm_might_need_to_copy(struct folio *folio, void rmap_walk_ksm(struct folio *folio, struct rmap_walk_control *rwc); void folio_migrate_ksm(struct folio *newfolio, struct folio *folio); - -#ifdef CONFIG_MEMORY_FAILURE -void collect_procs_ksm(struct page *page, struct list_head *to_kill, - int force_early); -#endif - -#ifdef CONFIG_PROC_FS +void collect_procs_ksm(struct folio *folio, struct page *page, + struct list_head *to_kill, int force_early); long ksm_process_profit(struct mm_struct *); -#endif /* CONFIG_PROC_FS */ #else /* !CONFIG_KSM */ @@ -120,12 +114,10 @@ static inline void ksm_might_unmap_zero_page(struct mm_struct *mm, pte_t pte) { } -#ifdef CONFIG_MEMORY_FAILURE -static inline void collect_procs_ksm(struct page *page, +static inline void collect_procs_ksm(struct folio *folio, struct page *page, struct list_head *to_kill, int force_early) { } -#endif #ifdef CONFIG_MMU static inline int ksm_madvise(struct vm_area_struct *vma, unsigned long start, diff --git a/mm/ksm.c b/mm/ksm.c index 8c001819cf10..7d032b52002f 100644 --- a/mm/ksm.c +++ b/mm/ksm.c @@ -3172,12 +3172,11 @@ void rmap_walk_ksm(struct folio *folio, struct rmap_walk_control *rwc) /* * Collect processes when the error hit an ksm page. */ -void collect_procs_ksm(struct page *page, struct list_head *to_kill, - int force_early) +void collect_procs_ksm(struct folio *folio, struct page *page, + struct list_head *to_kill, int force_early) { struct ksm_stable_node *stable_node; struct ksm_rmap_item *rmap_item; - struct folio *folio = page_folio(page); struct vm_area_struct *vma; struct task_struct *tsk; diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 1c3cf1fe4964..0630e34b583b 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -713,7 +713,7 @@ static void collect_procs(struct folio *folio, struct page *page, if (!folio->mapping) return; if (unlikely(folio_test_ksm(folio))) - collect_procs_ksm(page, tokill, force_early); + collect_procs_ksm(folio, page, tokill, force_early); else if (folio_test_anon(folio)) collect_procs_anon(folio, page, tokill, force_early); else