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: 110322 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp3501938vqr; Tue, 20 Jun 2023 01:06:44 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4y4J6+puy23AcnZkwC5EKh+vFAZ5s+VaQ16R26n6HKfBsIB2hl/Pg8M+A27LSY9VI8PLeO X-Received: by 2002:a05:6a21:398c:b0:119:54a7:1e61 with SMTP id ad12-20020a056a21398c00b0011954a71e61mr12297396pzc.22.1687248403937; Tue, 20 Jun 2023 01:06:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687248403; cv=none; d=google.com; s=arc-20160816; b=fEwXA7ZPwObBfrzjkcsuMVsISz9jL6cu731VfdG3oX+e2wHVhwKKRX0zkyD4geBDVS LTUW0kxtFF8s033cs+xKEUWQiOrZ/D793sk1Jrwy1KUltfGc6LnBA+WV+1BelBTsbzKi rXnKewoeS+JDTpqDikx5HdSmA71xH4JIfuZkrAhRKr0zPRUp93B4WjcuWJDPlZMSv2vI YfbN2SJHdvnGafdfHOPQhmzFVS9xt24SK8Rr6Jg2+0WNBhOwlkWDkaqvYbQ0MMk6Y9Yb ZrYCzOdpvmWkiEidCgWZonB6CKpClruGfUyp0O6IP4BmiITyyG40S+AhEGxxvX6kex4g lGRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:message-id:in-reply-to :subject:cc:to:from:date:dkim-signature; bh=JyT8tmsQKzrYxiMI/rVOY2yPaVbA/RNeIBfphNdBMF4=; b=L4QjvqBNb/x5IVuXs6ZfbaSvqD8tVOuYEfZrkYumhsbg77upZv1p20SvYfuUxRAnh8 TM07Rl8LCTjccGjBCLJMpgOmZdnx+HioXzwlZLZcUtqklW8X3Lv9nUBTbHBCxwuO0Ach RG1tO0etltlMDCVBFb5hdXYDeD4G05KNYpwdnvWmZj5TFoS1VZ0E81+OvvlMEYlyqeu8 b8PnPxO5kybsDWeTS3DQ1WulYqtIeDZRk0PSuq/sAS5icEBtX9+f8UtkeYTE13lQLmi9 /tJqfMEbOL7zYBXQmhM7mgsvm4sJ7+QBLmVOP6c/4AZdUWnBamfREtDSZ5ag8SU0jOHF ihyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=Wlyhpqj5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e28-20020aa7981c000000b00668802803fbsi1087224pfl.393.2023.06.20.01.06.29; Tue, 20 Jun 2023 01:06:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=Wlyhpqj5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231244AbjFTHuL (ORCPT + 99 others); Tue, 20 Jun 2023 03:50:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229595AbjFTHuJ (ORCPT ); Tue, 20 Jun 2023 03:50:09 -0400 Received: from mail-yw1-x112e.google.com (mail-yw1-x112e.google.com [IPv6:2607:f8b0:4864:20::112e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F67B172B for ; Tue, 20 Jun 2023 00:49:41 -0700 (PDT) Received: by mail-yw1-x112e.google.com with SMTP id 00721157ae682-5704fce0f23so47448457b3.3 for ; Tue, 20 Jun 2023 00:49:41 -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=XoQY8njBodNgYq1P3TlimrNmOxG3YHXYUduQhekqceTfaarVvS9NKqnZxT9RqqbQ9r aP+uP3iwNRqeQMihzzz9/+/y4E3fi0taQa/6rkkF3i9fYZAHNrcEguxCl58i8B7Cnv9A UEif3LqayRlv7BazoHeTn8GODOIuBfMvtShx7UoU8eaJZy6oWWgR+vv+4oqqpiwPp9YD LsW5zBBtNBLJve19lRvhVRwM0tqIl3yJe2XWeWxxywJYOIKkn3S8+UDoFvjUg3ktgib4 bSvV31CRok2hCEhO2gs+ztIsxK/4au+Eo7dghPEYbUWmY6z8Nc7gDrjjKXRQDJghHL9W 32tA== X-Gm-Message-State: AC+VfDz/82W14wFjkaQXHSD35OK9KfZs+0DLOHYIrC6y7QCSh7+pqxy6 mHCBhgx09hVR0l123I90d1TWIw== 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-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769208182339220500?= X-GMAIL-MSGID: =?utf-8?q?1769208182339220500?= 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) {