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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3BCCAC77B7E for ; Sat, 27 May 2023 15:48:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 86B08900002; Sat, 27 May 2023 11:48:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 818286B0072; Sat, 27 May 2023 11:48:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6B962900002; Sat, 27 May 2023 11:48:05 -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 5D93B6B0071 for ; Sat, 27 May 2023 11:48:05 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 279DA140174 for ; Sat, 27 May 2023 15:48:05 +0000 (UTC) X-FDA: 80836466130.24.CB5FCD1 Received: from mail-pj1-f45.google.com (mail-pj1-f45.google.com [209.85.216.45]) by imf20.hostedemail.com (Postfix) with ESMTP id 482931C0012 for ; Sat, 27 May 2023 15:48:03 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=bUL5aHRk; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf20.hostedemail.com: domain of alexander.duyck@gmail.com designates 209.85.216.45 as permitted sender) smtp.mailfrom=alexander.duyck@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1685202483; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=J49g5r+C8X2NVCkBgl8IzrTCMvTMcQQzUyfAMjxZsPg=; b=mT9lx52MrbdNHDhwMGSJapfQ7sP3KZMu+U3cvbAfjke/pasOTa7AbEqHIhiv0e8xxx6Zno E9lJERBjtTfQ8qu/Ey8DHfWWiPwlGEImumLxra9SUKswb6WPxg81ZZ1eYQYmGqkH2b++5r DuxkNVdWFZ5RGQjqukh87iZLU1LR1sM= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=bUL5aHRk; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf20.hostedemail.com: domain of alexander.duyck@gmail.com designates 209.85.216.45 as permitted sender) smtp.mailfrom=alexander.duyck@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1685202483; a=rsa-sha256; cv=none; b=ew2y1m7wAiqAP1Q267RxnTPFFYNXi1iuV8RWnjvFMUd7HPB4rMPPcbUS83PPQYGTJ5Ak4C 2ofJO2IZh/2zYbFxc20wX3WAuN8+fW3N61xWKTOJZzPQZXtsPR5FDmoD1Sdtxh564QOyjt /WRx/7JMRm+RXym4BqIniL7wgTXROiE= Received: by mail-pj1-f45.google.com with SMTP id 98e67ed59e1d1-2563fa9b27bso1030763a91.3 for ; Sat, 27 May 2023 08:48:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1685202482; x=1687794482; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:from:to:cc:subject :date:message-id:reply-to; bh=J49g5r+C8X2NVCkBgl8IzrTCMvTMcQQzUyfAMjxZsPg=; b=bUL5aHRkLeXZgL9zLh88p3YSSEdIcCAWRafE5CCYjGxTY3b4C3Nvx9HyPTyr/MFIOy XNJoF8YCF/UuX9K7KUHu0+XrePH07oMRCWX8Xbo1x7sNks0uPXrC7DyAE2YZ4nRJbxmX R+vS/qobWvWDwbY/vp3IFGaoobPrHdxLodkySGURPv0utOVIMAyhkSVf+YGDr2He0s2+ mFeAz0s4hFMt6E5OhaapTV9xjhbS5h7hmrocjChFeleEtRzzQxiyNpffZQ1mkdD3wp6N kwic0v4RCyjRUeyXdYulrgWtKqFCkPBnTY7+z+AWj+P7a+4sVK3Mo/U26rqt0pp8KAYf 6I9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685202482; x=1687794482; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=J49g5r+C8X2NVCkBgl8IzrTCMvTMcQQzUyfAMjxZsPg=; b=fduTvlaQDScz611WPDwmaLjNY4UshH+bWCnMbnWzMfiHdmmEJxb2KDfKeXuPIdDUGT 8AU0S2UijAid4wPw0bUPBzGyCyi1yVLjo11X18DKwbWv0OGoSTKFQSQtYXPs4QIFxkFg l0jWvH/UNmdHQGOfPx1TbJ6AxwhDc/vO2Qcl+ue4j5F2zMSJs6astXvHVQRihGSqIDdW BZwcvJanxzwWrXh0XRWRRSOX9jqAzuimfk2GM06lDfE6AyJ3JVJkQmrUEqnDvGXt+t0C fsUezgku/jNgmcFUPpikuGFLthRJmNtm+4ZBqFKBNQ9OavfUX2gxdcjdOSyBza+ca8iA CtNw== X-Gm-Message-State: AC+VfDwwYGyygps3LE11EW+gE7ohb6dfZKuLhiPCnHK9HVEmzCx/iNwS MBXB17hhTkm0sqrqCgI1X+U= X-Google-Smtp-Source: ACHHUZ7QPh85GAe4qtDoAAFctO3cPI86At/IRUfb5BaooKwKJwDEqjmatrKZ0/p6N1NdUk4vgS+bMw== X-Received: by 2002:a17:90a:7021:b0:250:7d1f:938b with SMTP id f30-20020a17090a702100b002507d1f938bmr6504460pjk.23.1685202481899; Sat, 27 May 2023 08:48:01 -0700 (PDT) Received: from ?IPv6:2605:59c8:448:b800:82ee:73ff:fe41:9a02? ([2605:59c8:448:b800:82ee:73ff:fe41:9a02]) by smtp.googlemail.com with ESMTPSA id 5-20020a17090a000500b00253311d508esm6598798pja.27.2023.05.27.08.47.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 May 2023 08:48:01 -0700 (PDT) Message-ID: Subject: Re: [PATCH net-next 04/12] mm: Make the page_frag_cache allocator use multipage folios From: Alexander H Duyck To: Yunsheng Lin , David Howells , netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Willem de Bruijn , David Ahern , Matthew Wilcox , 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 Date: Sat, 27 May 2023 08:47:58 -0700 In-Reply-To: References: <20230524153311.3625329-1-dhowells@redhat.com> <20230524153311.3625329-5-dhowells@redhat.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.44.4 (3.44.4-3.fc36) MIME-Version: 1.0 X-Rspamd-Queue-Id: 482931C0012 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: xsqdkjtyiy1ppnfo57wuob64deeofpdz X-HE-Tag: 1685202483-763856 X-HE-Meta: U2FsdGVkX1/uWK7IerNy32z+CSWElKzxolPWWlAD6WkyTGxB6U94JMP60iafPoFm8A0QPlTIwya9eWs7Rkr5UxC3pjkkYEABcKhyIUo7KdZSmcneuszOxkEa9idxtpnfaIGanbkkTPOjRySz8kqkmIz+Q/kYE5VP1Ii5QUyF9ciKz8JwQhKn+4/VcBsGkQJ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M/pzWX4p+Xs7jsoAuEG31UgtFoIWhWPibD+/heKlIyoPvsoJ6NayOt+M2gLH3+Mpxil6wemn2O8Ws1lO7oHwloApzc6Is5/JUudz0vXObs2vjYhxQWSm1ZTxqT+FmRaNA+Dz6hZxO0WWlCYl+8e89rySbxjHKNe8AvaNJxd/em5z6W7+p6MK5KVanaBEgEWui6hVIip8HZefE+zcyCckTquDS1q8UwxwUWUbjdBa4h4DdtKJmrhIicKv/F3l8z+NuUdHVqe2Efq9nK2uiPUzs1S7GfDpBW4 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: On Fri, 2023-05-26 at 19:56 +0800, Yunsheng Lin wrote: > On 2023/5/24 23:33, David Howells wrote: > > Change the page_frag_cache allocator to use multipage folios rather tha= n > > groups of pages. This reduces page_frag_free to just a folio_put() or > > put_page(). >=20 > Hi, David >=20 > put_page() is not used in this patch, perhaps remove it to avoid > the confusion? > Also, Is there any significant difference between __free_pages() > and folio_put()? IOW, what does the 'reduces' part means here? >=20 > 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? >=20 > >=20 > > 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 foli= o *folio) > > } > > =20 > > 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; > > }; >=20 > 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 pat= ch? > It might be worth calling that out in the commit log or split it into ano= ther > patch to make it clearer and easier to review? Yes, there is a cost for going from page to virtual address. That is why we only use the page when we finally get to freeing or resetting the pagecnt_bias. Also I have some concerns about going from page to folio as it seems like the folio_alloc setups the transparent hugepage destructor instead of using the compound page destructor. I would think that would slow down most users as it looks like there is a spinlock that is taken in the hugepage destructor that isn't there in the compound page destructor.