From mboxrd@z Thu Jan 1 00:00:00 1970 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 43E9EC77B73 for ; Tue, 6 Jun 2023 19:04:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=lsn0Oe1VTjK1YFcJq+oCXmWzHnacGrSE+9UJkaPamm4=; b=up2RUSOlaigRkD DC0Yl1B/L9obIRMhmO3wbS4zQvYD8rdmb1r0UAzDoCgQWgtRotQc5yqqfDu+P7kAdaYyyJlJhTU3Y uxkZ/uYA4BMPVbEIwRr34atpcYxyp8pH+layLFvYb5s8yN05zdGON4Y44rHUM23mrXAvoUW8R85Ti S168AeB+dIOW2HZqQ8RLprRg0se0Qg0pXLiQ+8FzQUxC3r2MNDwKt8ysp5HIM6D3PX0s8uUlvpuQD HFxm4LFKhzavXojtk/kolo+vzi5dz+5BG2xiddmeW6faQZEQF3aT2rgyj0bUVyz5cj3eptwzlVFYO /3mQD088oSykIJ6xUaMA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q6by6-002s6o-0l; Tue, 06 Jun 2023 19:03:46 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q6by2-002s3P-1F for linux-arm-kernel@lists.infradead.org; Tue, 06 Jun 2023 19:03:45 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686078218; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=bmPwhcLQLS6QAOJhnaZRrlptzdg2mUtfNMjjPY6LfS8=; b=AFuQrzjWZt9DInEY1lFNe2Dkl2jWUeOnZvEx5qHaeGepugKSmH3uiA6RXeZM6tL2ddVh48 DmlcdnHCQCHqUaJaJTJi4xa7fyWwzBuf0roPU+B8OJVu5y5PjQqcZGmW0Z02eAWTJ5Qn2d evCVBAC6WjTzbhU7/EYtMPaLsJ+bbMg= Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-195-Q5X4OKwMO8SXNnpOMCrK7g-1; Tue, 06 Jun 2023 15:03:37 -0400 X-MC-Unique: Q5X4OKwMO8SXNnpOMCrK7g-1 Received: by mail-qk1-f200.google.com with SMTP id af79cd13be357-75b147a2548so130957685a.1 for ; Tue, 06 Jun 2023 12:03:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686078216; x=1688670216; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=bmPwhcLQLS6QAOJhnaZRrlptzdg2mUtfNMjjPY6LfS8=; b=Q1wdy7a94BigEIfWtkpFdNV5b1ZnrdLaLnZChdxxpGG2RteWq08G8l23kxzK6pwKxt 385bfO+FZZvTd/4ZwpPl/PEMINKGbhV50BYYBJ/O1+8sr0BuO/dxew6SlUIbGUJ6tsVm +aHfsuAzrBJryvz5ggHoEJ2v1f2+leMGE6csLfmMJcdU/Dwl49dTsDPZkWrMkBWedWuQ W6fDhyWKjPh45gqWuYXDwKmvFR0nYmc/eD2a0rMBfWDqS8IqVezeFf5cwSyIFAlj0DMQ EbSZrvRqg7U87T4yhpcmKm7UkuPVH0Sc9ng3HCTXGvNHr4EW7FUZBlRvuiDUOs9DZlo7 iz+A== X-Gm-Message-State: AC+VfDw2nCw2OCinITLBNRW3i0EPFeSu3oF1imjpqPIFw+0Gj2ALmdau 7r7isci/OiPdEeK7QRf4M5zrKx2PZVaam6KYLapQYRoV/ozUQIWegibzYJzM4gXuSjks6Vl8orz 67IykuoM0UBZUfdlMmNGFl3MVl16r5N08ck8= X-Received: by 2002:a05:620a:2b92:b0:75b:23a1:69f0 with SMTP id dz18-20020a05620a2b9200b0075b23a169f0mr3107583qkb.7.1686078216677; Tue, 06 Jun 2023 12:03:36 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5C5YMccZA+iUS9RAssWOgobvDgS7+Te3WrU+7dZkM3FviCtXVqQlWbzikNWhoOiLhOPK8t2g== X-Received: by 2002:a05:620a:2b92:b0:75b:23a1:69f0 with SMTP id dz18-20020a05620a2b9200b0075b23a169f0mr3107557qkb.7.1686078216403; Tue, 06 Jun 2023 12:03:36 -0700 (PDT) Received: from x1n (cpe5c7695f3aee0-cm5c7695f3aede.cpe.net.cable.rogers.com. [99.254.144.39]) by smtp.gmail.com with ESMTPSA id d14-20020a05620a166e00b0074636e35405sm5100311qko.65.2023.06.06.12.03.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Jun 2023 12:03:35 -0700 (PDT) Date: Tue, 6 Jun 2023 15:03:31 -0400 From: Peter Xu To: Jason Gunthorpe Cc: Hugh Dickins , Matthew Wilcox , Andrew Morton , Mike Kravetz , Mike Rapoport , "Kirill A. Shutemov" , David Hildenbrand , Suren Baghdasaryan , Qi Zheng , Yang Shi , Mel Gorman , Peter Zijlstra , Will Deacon , Yu Zhao , Alistair Popple , Ralph Campbell , Ira Weiny , Steven Price , SeongJae Park , Naoya Horiguchi , Christophe Leroy , Zack Rusin , 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 , 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: Re: [PATCH 05/12] powerpc: add pte_free_defer() for pgtables sharing page Message-ID: References: <35e983f5-7ed3-b310-d949-9ae8b130cdab@google.com> <28eb289f-ea2c-8eb9-63bb-9f7d7b9ccc11@google.com> <4df4909f-f5dd-6f94-9792-8f2949f542b3@google.com> MIME-Version: 1.0 In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230606_120342_552945_1EBB68B4 X-CRM114-Status: GOOD ( 24.11 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, Jun 06, 2023 at 03:23:30PM -0300, Jason Gunthorpe wrote: > On Mon, Jun 05, 2023 at 08:40:01PM -0700, Hugh Dickins wrote: > > > diff --git a/arch/powerpc/mm/pgtable-frag.c b/arch/powerpc/mm/pgtable-frag.c > > index 20652daa1d7e..e4f58c5fc2ac 100644 > > --- a/arch/powerpc/mm/pgtable-frag.c > > +++ b/arch/powerpc/mm/pgtable-frag.c > > @@ -120,3 +120,54 @@ void pte_fragment_free(unsigned long *table, int kernel) > > __free_page(page); > > } > > } > > + > > +#ifdef CONFIG_TRANSPARENT_HUGEPAGE > > +#define PTE_FREE_DEFERRED 0x10000 /* beyond any PTE_FRAG_NR */ > > + > > +static void pte_free_now(struct rcu_head *head) > > +{ > > + struct page *page; > > + int refcount; > > + > > + page = container_of(head, struct page, rcu_head); > > + refcount = atomic_sub_return(PTE_FREE_DEFERRED - 1, > > + &page->pt_frag_refcount); > > + if (refcount < PTE_FREE_DEFERRED) { > > + pte_fragment_free((unsigned long *)page_address(page), 0); > > + return; > > + } > > From what I can tell power doesn't recycle the sub fragment into any > kind of free list. It just waits for the last fragment to be unused > and then frees the whole page. > > So why not simply go into pte_fragment_free() and do the call_rcu directly: > > BUG_ON(atomic_read(&page->pt_frag_refcount) <= 0); > if (atomic_dec_and_test(&page->pt_frag_refcount)) { > if (!kernel) > pgtable_pte_page_dtor(page); > call_rcu(&page->rcu_head, free_page_rcu) We need to be careful on the lock being freed in pgtable_pte_page_dtor(), in Hugh's series IIUC we need the spinlock being there for the rcu section alongside the page itself. So even if to do so we'll need to also rcu call pgtable_pte_page_dtor() when needed. -- Peter Xu _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel