From patchwork Tue Jun 20 07:49:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 13285279 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 1E319EB64D7 for ; Tue, 20 Jun 2023 07:49:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 927268D0003; Tue, 20 Jun 2023 03:49:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8B0A88D0001; Tue, 20 Jun 2023 03:49:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 729048D0003; Tue, 20 Jun 2023 03:49:42 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 619918D0001 for ; Tue, 20 Jun 2023 03:49:42 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 33DB514064C for ; Tue, 20 Jun 2023 07:49:42 +0000 (UTC) X-FDA: 80922351804.01.D44FB40 Received: from mail-yw1-f178.google.com (mail-yw1-f178.google.com [209.85.128.178]) by imf22.hostedemail.com (Postfix) with ESMTP id 58825C0005 for ; Tue, 20 Jun 2023 07:49:40 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=Wlyhpqj5; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf22.hostedemail.com: domain of hughd@google.com designates 209.85.128.178 as permitted sender) smtp.mailfrom=hughd@google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1687247380; 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-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=JyT8tmsQKzrYxiMI/rVOY2yPaVbA/RNeIBfphNdBMF4=; b=Y5XZTVvYj3wajSuczhiA5Z80uNpVuqv2X3j7+SM9xE/cPCmGGkgQ3ZXp2+GLnT8s2w0dEw NTYGR6SETI0lrVCFtv1Ba8fZkZgVzZIB2olnNeQ7ceaN12yQE5mGcVSqWkey0g7cCP4WCb gZtJTZXaBHGr8mLOgt9wSLmFpr5x3RM= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=Wlyhpqj5; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf22.hostedemail.com: domain of hughd@google.com designates 209.85.128.178 as permitted sender) smtp.mailfrom=hughd@google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1687247380; a=rsa-sha256; cv=none; b=sG61p0phFL5MEBDvmDlGPeXMlCX+/7HVGZeUDwFVU1uSO70V+DpgSO+7D00cKZvAf6KN6d fD5uU96h61tz7gLfLw9DqPykxukyxXQnJ590mwJcG5PpoJMUbq3aC/x8yfZoOZUrXBZNY+ rjB7RLhg4xgpFfaVWGqnI1M9tvBmypI= Received: by mail-yw1-f178.google.com with SMTP id 00721157ae682-5703d12ab9aso47583187b3.2 for ; Tue, 20 Jun 2023 00:49:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1687247379; x=1689839379; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to; bh=JyT8tmsQKzrYxiMI/rVOY2yPaVbA/RNeIBfphNdBMF4=; b=Wlyhpqj5qzfuvutrjOa/4V6PuPsDCDOgWHtSW/4kwbuOkurc1q0KurhYLqHW1JVDng ocfjumMCL+5VTdlkv6JFAWzHFSaf/DQcTveKuW/F1nUw+Sj6E3jgL+8I+UQrrKTcSspC zGEBBcceErIi3jvfUdE8XIwgkG18lQEbl2V2HS4GGiBXkvY4t9/NkaOVpMEahcggUUzl u8oefzeOOrLLnM3RkTGo6WsoKQCjwWkScujGOaUdyRth+pzrlMusEw0XYP/BcTSABeYV rleoq5m+PuifcHOelghsbpsP6kubTOIzWI9OP98uqMngj6OJlbnVDdZn1qt2293RkTnb aaaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687247379; x=1689839379; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=JyT8tmsQKzrYxiMI/rVOY2yPaVbA/RNeIBfphNdBMF4=; b=U3WVVlkVRNSOcybeHPmhpbWqXYFoxVpxyS9tQyPjeuhSGtax7LyY3+D0/WkEipLk6C LfZ9e5NsG07YRj/TwvW+EwPmgNmd96pF3bFbThNTCS73eSfqbc6svkOI8D2H1ZNAhvWA tyG3G5BdoMnKg9qgU0TUB2Tp/Q1fTgpmfHoWSxExYl6YLfJXdM12WbQg65hH98XT/42H SbgoOsv3xJzf2O6uscmpBSmj/AyE9x5i5b9mUb4JW0zLkNkRXCCijZjUidwFlIWV/1sJ Ki/XJHz2eftSNm4jJ3YQPjbjClDnmbezkM4YYtqslJI3qR4QAUnlmJklJT3v+S24PfZy qzDg== X-Gm-Message-State: AC+VfDytRZrNhaVsVsFcPMrw95+hB0INlfu12sN8m8nfXdsp/b/H4J0m fZghdgo7qmNzlkibV/ykxz282g== X-Google-Smtp-Source: ACHHUZ5+IOPW+qBQbjfJiBwfK7g3HrB1Jv9bM1vDxBV2sAeLMGBBrGsscHleOg916F+4k1/7bPeS5w== X-Received: by 2002:a81:8311:0:b0:568:d63e:dd2c with SMTP id t17-20020a818311000000b00568d63edd2cmr10308263ywf.11.1687247379257; Tue, 20 Jun 2023 00:49:39 -0700 (PDT) Received: from ripple.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id o17-20020a0dcc11000000b005702597583fsm381836ywd.26.2023.06.20.00.49.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Jun 2023 00:49:38 -0700 (PDT) Date: Tue, 20 Jun 2023 00:49:34 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@ripple.attlocal.net To: Andrew Morton cc: Gerald Schaefer , Vasily Gorbik , Mike Kravetz , Mike Rapoport , "Kirill A. Shutemov" , Matthew Wilcox , David Hildenbrand , Suren Baghdasaryan , Qi Zheng , Yang Shi , Mel Gorman , Peter Xu , Peter Zijlstra , Will Deacon , Yu Zhao , Alistair Popple , Ralph Campbell , Ira Weiny , Steven Price , SeongJae Park , Lorenzo Stoakes , Huang Ying , Naoya Horiguchi , Christophe Leroy , Zack Rusin , Jason Gunthorpe , Axel Rasmussen , Anshuman Khandual , Pasha Tatashin , Miaohe Lin , Minchan Kim , Christoph Hellwig , Song Liu , Thomas Hellstrom , Russell King , "David S. Miller" , Michael Ellerman , "Aneesh Kumar K.V" , Heiko Carstens , Christian Borntraeger , Claudio Imbrenda , Alexander Gordeev , Jann Horn , Vishal Moola , Vlastimil Babka , linux-arm-kernel@lists.infradead.org, sparclinux@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v2 06/12] sparc: add pte_free_defer() for pte_t *pgtable_t In-Reply-To: <54cb04f-3762-987f-8294-91dafd8ebfb0@google.com> Message-ID: References: <54cb04f-3762-987f-8294-91dafd8ebfb0@google.com> MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: fu4cz9cdnwfzson731xuwpqbwidxiqip X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 58825C0005 X-HE-Tag: 1687247380-259687 X-HE-Meta: U2FsdGVkX19PFl38W3LHDHEo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w5MPeOOMe3jwdKDBGkEKG1oGgwp30PC20VSbcZJoinpbpZMh4S9QL0cKQ7+1uM8pZa42rOvqi1UK0WwkIq5LQttIZ6+lLW5B0d34WqM6JzfCRHUlyRg5CGFy04pmD6twlvlJS5Mx/abUl+apcc0p0j7lhoYFRkSCNMl/zCSS4JapnLXHie5HCd1KcyzyHZbxql6K9I0njAoUSJKIbrHvG4VRBIcPWt2ke0o7Sw8wVRvpLA3rENKbE6XypLWzHYrjZ30HDPrs/24DXdqrS4uMvXdZ7jRZUSqwqy8fTnOUHDOI73xRAJRqKxeNDp7sCogkG7fn3lgLUdUbNxVirh5XxjcTqyHt/JzC2P0s0nda9MGYEubBywgesQ0aNm8k3Sk6PHrov44wSRsvl 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: Add sparc-specific pte_free_defer(), to call pte_free() via call_rcu(). pte_free_defer() will be called inside khugepaged's retract_page_tables() loop, where allocating extra memory cannot be relied upon. This precedes the generic version to avoid build breakage from incompatible pgtable_t. sparc32 supports pagetables sharing a page, but does not support THP; sparc64 supports THP, but does not support pagetables sharing a page. So the sparc-specific pte_free_defer() is as simple as the generic one, except for converting between pte_t *pgtable_t and struct page *. Signed-off-by: Hugh Dickins --- arch/sparc/include/asm/pgalloc_64.h | 4 ++++ arch/sparc/mm/init_64.c | 16 ++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/arch/sparc/include/asm/pgalloc_64.h b/arch/sparc/include/asm/pgalloc_64.h index 7b5561d17ab1..caa7632be4c2 100644 --- a/arch/sparc/include/asm/pgalloc_64.h +++ b/arch/sparc/include/asm/pgalloc_64.h @@ -65,6 +65,10 @@ pgtable_t pte_alloc_one(struct mm_struct *mm); void pte_free_kernel(struct mm_struct *mm, pte_t *pte); void pte_free(struct mm_struct *mm, pgtable_t ptepage); +/* arch use pte_free_defer() implementation in arch/sparc/mm/init_64.c */ +#define pte_free_defer pte_free_defer +void pte_free_defer(struct mm_struct *mm, pgtable_t pgtable); + #define pmd_populate_kernel(MM, PMD, PTE) pmd_set(MM, PMD, PTE) #define pmd_populate(MM, PMD, PTE) pmd_set(MM, PMD, PTE) diff --git a/arch/sparc/mm/init_64.c b/arch/sparc/mm/init_64.c index 04f9db0c3111..0d7fd793924c 100644 --- a/arch/sparc/mm/init_64.c +++ b/arch/sparc/mm/init_64.c @@ -2930,6 +2930,22 @@ void pgtable_free(void *table, bool is_page) } #ifdef CONFIG_TRANSPARENT_HUGEPAGE +static void pte_free_now(struct rcu_head *head) +{ + struct page *page; + + page = container_of(head, struct page, rcu_head); + __pte_free((pgtable_t)page_address(page)); +} + +void pte_free_defer(struct mm_struct *mm, pgtable_t pgtable) +{ + struct page *page; + + page = virt_to_page(pgtable); + call_rcu(&page->rcu_head, pte_free_now); +} + void update_mmu_cache_pmd(struct vm_area_struct *vma, unsigned long addr, pmd_t *pmd) {