Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2371389rwd; Fri, 26 May 2023 05:54:17 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5zpP1f0JD9a1Xpla6IdOqwucRhgetPSSIee5cUOb5RiZrIdbxMAGD6Sn5vMcnG8XoLApMI X-Received: by 2002:a05:6a00:1883:b0:64a:f8c9:a42c with SMTP id x3-20020a056a00188300b0064af8c9a42cmr3614982pfh.18.1685105657010; Fri, 26 May 2023 05:54:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685105656; cv=none; d=google.com; s=arc-20160816; b=LaHkhnjyYpIPNqBRJ6V8f8BAgYeko0eEqOZzzox3LWYiEDAZn3WYYTWj4KjlrIf5+r rNqponICJCJTZCKoRD/zYk/B8sY0UjHFjrJHj/LWepysFIkdgcSTmk0sy3yN8+HzCSjQ SydU9CF7if538sZYjldjlPOSMJmsDN6UEQ9608KnJtWrtrymoVeKsXpJyzZaioG11oPN RcVzZbpU2xlt9axdd5uoGrTYNrFxAqIjjNyq6c0DcBaiMxjKqI4wfyt/BoXLu54b2J9b 0NqF4sTWAQeaUIgLli+6H82mLaMf4E0OKY2sljVRxak/LPh1jKupB50ImdKi9lOxgivj G7ww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:content-transfer-encoding :content-id:mime-version:subject:cc:to:references:in-reply-to:from :organization:dkim-signature; bh=7wL75rzvxRHHweMkIElV/+uTCkQTaYtKC4NiLzMuw0M=; b=hzPsTtBpZ9mnOxpHygSE42HcY4EPtpLKfFHctYs2hEvTaXzJ8cxpLDzN1UGSl7hxWw AYvVzhG78mSVUNUfISFtZAcBoZUsJLXAMIoF1A2s9mDBHQHSq0BpFQgR1Eyw63kfcNPT fgKuipbreiCee5aRHdzuRpL26zDVkiO3J5u7wbqsYGNUUsjvJHGArkDKUus88Ok7UEXU p7SPfPseME1oLfS/6CIhe6WTei1mzbEU9n4BT+XI+3as0E1pa8UP8QmlrRpctSPjI2Ov 75sPCAQHUkh45doY3orR10AATFO8t0Et88JV8M1lWeTDN8TAK6b/sRBe4OtAymbqPVDy uBfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Aq5nl1aW; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r1-20020aa79621000000b0063d48d82e85si4183761pfg.15.2023.05.26.05.54.02; Fri, 26 May 2023 05:54:16 -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=@redhat.com header.s=mimecast20190719 header.b=Aq5nl1aW; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236978AbjEZMr7 (ORCPT + 99 others); Fri, 26 May 2023 08:47:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41040 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230366AbjEZMr6 (ORCPT ); Fri, 26 May 2023 08:47:58 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D3299195 for ; Fri, 26 May 2023 05:47:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685105231; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7wL75rzvxRHHweMkIElV/+uTCkQTaYtKC4NiLzMuw0M=; b=Aq5nl1aWB1JuRjOFASFkWAfR8hir6DkHqa0T946u8YDra0ysgJ4E4JMSw2EjSrm6CYRF8q EPv7quDgoTj2fTqaLaAsf1JWtPS22GsVldMlW9r3aAOIsTsIeO/r+eM3tBY7zRAiN8A8hv B2J+U/VC++ZNNA8BELaUqc9o2cz61KM= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-657-xgCvy8lSNa2E1PbJrJo26w-1; Fri, 26 May 2023 08:47:08 -0400 X-MC-Unique: xgCvy8lSNa2E1PbJrJo26w-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8F54A811E8E; Fri, 26 May 2023 12:47:06 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.39.192.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7742C8162; Fri, 26 May 2023 12:47:01 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 From: David Howells In-Reply-To: References: <20230524153311.3625329-1-dhowells@redhat.com> <20230524153311.3625329-5-dhowells@redhat.com> To: Yunsheng Lin , Matthew Wilcox cc: David Howells , netdev@vger.kernel.org, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Willem de Bruijn , David Ahern , Jens Axboe , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Jeroen de Borst , Catherine Sullivan , Shailend Chand , Felix Fietkau , John Crispin , Sean Wang , Mark Lee , Lorenzo Bianconi , Matthias Brugger , AngeloGioacchino Del Regno , Keith Busch , Jens Axboe , Christoph Hellwig , Sagi Grimberg , Chaitanya Kulkarni , Andrew Morton , linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-nvme@lists.infradead.org Subject: Re: [PATCH net-next 04/12] mm: Make the page_frag_cache allocator use multipage folios MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <739165.1685105220.1@warthog.procyon.org.uk> Content-Transfer-Encoding: quoted-printable Date: Fri, 26 May 2023 13:47:00 +0100 Message-ID: <739166.1685105220@warthog.procyon.org.uk> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham 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 Yunsheng Lin wrote: > > Change the page_frag_cache allocator to use multipage folios rather th= an > > groups of pages. This reduces page_frag_free to just a folio_put() or > > put_page(). > = > put_page() is not used in this patch, perhaps remove it to avoid > the confusion? Will do if I need to respin the patches. > Also, Is there any significant difference between __free_pages() > and folio_put()? IOW, what does the 'reduces' part means here? I meant that the folio code handles page compounding for us and we don't n= eed to work out how big the page is for ourselves. If you look at __free_pages(), you can see a PageHead() call. folio_put() doesn't need that. > I followed some disscusion about folio before, but have not really > understood about real difference between 'multipage folios' and > 'groups of pages' yet. Is folio mostly used to avoid the confusion > about whether a page is 'headpage of compound page', 'base page' or > 'tailpage of compound page'? Or is there any abvious benefit about > folio that I missed? There is a benefit: a folio pointer always points to the head page and so = we never need to do "is this compound? where's the head?" logic to find it. = When going from a page pointer, we still have to find the head. Ultimately, the aim is to reduce struct page to a typed pointer to massive= ly reduce the amount of space consumed by mem_map[]. A page struct will then point at a folio or a slab struct or one of a number of different types. = But to get to that point, we have to stop a whole lot of things from using pag= e structs, but rather use some other type, such as folio. Eventually, there won't be a need for head pages and tail pages per se - j= ust memory objects of different sizes. > > diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h > > index 306a3d1a0fa6..d7c52a5979cc 100644 > > --- a/include/linux/mm_types.h > > +++ b/include/linux/mm_types.h > > @@ -420,18 +420,13 @@ static inline void *folio_get_private(struct fol= io *folio) > > } > > = > > struct page_frag_cache { > > - void * va; > > -#if (PAGE_SIZE < PAGE_FRAG_CACHE_MAX_SIZE) > > - __u16 offset; > > - __u16 size; > > -#else > > - __u32 offset; > > -#endif > > + struct folio *folio; > > + unsigned int offset; > > /* we maintain a pagecount bias, so that we dont dirty cache line > > * containing page->_refcount every time we allocate a fragment. > > */ > > - unsigned int pagecnt_bias; > > - bool pfmemalloc; > > + unsigned int pagecnt_bias; > > + bool pfmemalloc; > > }; > = > It seems 'va' and 'size' field is used to avoid touching 'stuct page' to > avoid possible cache bouncing when there is more frag can be allocated > from the page while other frags is freed at the same time before this pa= tch? Hmmm... fair point, though va is calculated from the page pointer on most arches without the need to dereference struct page (only arc, m68k and spa= rc define WANT_PAGE_VIRTUAL). David