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 8DC48C433EF for ; Fri, 13 May 2022 23:17:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 159346B0073; Fri, 13 May 2022 19:17:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 109A66B0075; Fri, 13 May 2022 19:17:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EEC446B0078; Fri, 13 May 2022 19:17:32 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id E14156B0073 for ; Fri, 13 May 2022 19:17:32 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay11.hostedemail.com (Postfix) with ESMTP id B0955807D8 for ; Fri, 13 May 2022 23:17:32 +0000 (UTC) X-FDA: 79462283544.19.82F5F99 Received: from mail-pj1-f47.google.com (mail-pj1-f47.google.com [209.85.216.47]) by imf16.hostedemail.com (Postfix) with ESMTP id 774421800D5 for ; Fri, 13 May 2022 23:17:22 +0000 (UTC) Received: by mail-pj1-f47.google.com with SMTP id j10-20020a17090a94ca00b001dd2131159aso12122690pjw.0 for ; Fri, 13 May 2022 16:17:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=LhHYT+qx/v0GgkbfrbEswAweJ78gI1G9mVkANF8vqZI=; b=KzTu9TMpoGnfSfAvjQPdi5+ResHs1uOyG3c0g+hQz2lukHkORc3khqOXhZ7IVAZ/vk Cas+lmgDGwy7DYeJqbMulZ+WW8udFjOXFtmClG0gYhFtC5DqiJgliD2Xol5sX+eFe91G bbH0B32kPndnlAvtqpJm5olmNkVzDUYneput7HUovEF1Yep+78hnzjc48u+R6OOEuBCE lBTw14v83VCWCd8xaTyzjc4poZzgLNkDWxs9Ce5P9r/NUvQxglri1krfMkKYK5I7raYP yjRNKQ0rnyiJiEeEqmMwdMfZeDBH466dpkeRZpiusoRtBmrip/88nQHwqIy4R2tLOMrF +F+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=LhHYT+qx/v0GgkbfrbEswAweJ78gI1G9mVkANF8vqZI=; b=uXhlK3ii6kIP4VgsrRbBGj4RvxXR4zG+MHP2bs8pfmD6+Iy0TrG8fCSaFPICNu1g7Q nVU1zi1OI/35bkkghbZ/8gv2d1zhH3kF/5z4mT1i2u+3XBkDBGcqZfyypaz2Czmoy1qP OTLPwG4D69clXH7NsM4AX0LlHX+326JwA+qAKVj6Mlqt3xnkKeCi78yHrN5Ohqj5l+a7 RYFHT/fGQiDTMb2mv4M7bH1az8BssYPoojR0JjrvREkKpGSlPXfVmtUJ7mHQySJ+JnEl mPd/Vvq7BU5J9yWtkN5tAfmCgdG995pcS/PE4g28CWXSv/iGCnv7tv3sW6XR9riRGxoP chCQ== X-Gm-Message-State: AOAM531sTC97GtB0IWaktb8RyqWWdWkmovmkqI62FV4Zu3jtPVagW2rE 4gwo8NQSEtE9ySxgzusahReXdNt6QPBXi+XWhN8= X-Google-Smtp-Source: ABdhPJz0CUAzdJymbgmIrGIlsahZ61Th6f3fpkA77gYTx/xCOYi0YA4jY9ebqDfkp4657T/J7YVsjjQ9tbHW9mqhdwY= X-Received: by 2002:a17:903:32c6:b0:15e:c1cc:2405 with SMTP id i6-20020a17090332c600b0015ec1cc2405mr6751108plr.117.1652483851323; Fri, 13 May 2022 16:17:31 -0700 (PDT) MIME-Version: 1.0 References: <20220504214437.2850685-1-zokeefe@google.com> <20220504214437.2850685-5-zokeefe@google.com> In-Reply-To: From: Yang Shi Date: Fri, 13 May 2022 16:17:18 -0700 Message-ID: Subject: Re: [PATCH v5 04/13] mm/khugepaged: make hugepage allocation context-specific To: "Zach O'Keefe" Cc: David Rientjes , Alex Shi , David Hildenbrand , Matthew Wilcox , Michal Hocko , Pasha Tatashin , Peter Xu , SeongJae Park , Song Liu , Vlastimil Babka , Zi Yan , Linux MM , Andrea Arcangeli , Andrew Morton , Arnd Bergmann , Axel Rasmussen , Chris Kennelly , Chris Zankel , Helge Deller , Hugh Dickins , Ivan Kokshaysky , "James E.J. Bottomley" , Jens Axboe , "Kirill A. Shutemov" , Matt Turner , Max Filippov , Miaohe Lin , Minchan Kim , Patrick Xia , Pavel Begunkov , Thomas Bogendoerfer Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 774421800D5 X-Stat-Signature: 4ju8mujxxyy7jhsdzidjh9ugkoypz5rw Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=KzTu9TMp; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf16.hostedemail.com: domain of shy828301@gmail.com designates 209.85.216.47 as permitted sender) smtp.mailfrom=shy828301@gmail.com X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1652483842-36253 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, May 13, 2022 at 4:05 PM Zach O'Keefe wrote: > > Thanks for the review, David! > > On Thu, May 12, 2022 at 1:02 PM David Rientjes wrote: > > > > On Wed, 4 May 2022, Zach O'Keefe wrote: > > > > > diff --git a/mm/khugepaged.c b/mm/khugepaged.c > > > index c94bc43dff3e..6095fcb3f07c 100644 > > > --- a/mm/khugepaged.c > > > +++ b/mm/khugepaged.c > > > @@ -92,6 +92,10 @@ struct collapse_control { > > > > > > /* Last target selected in khugepaged_find_target_node() */ > > > int last_target_node; > > > + > > > + struct page *hpage; > > > + int (*alloc_charge_hpage)(struct mm_struct *mm, > > > + struct collapse_control *cc); > > > }; > > > > > > /** > > > > Embedding this function pointer into collapse_contol seems like it would > > need some pretty strong rationale. Not to say that it should be a > > non-starter, but I think the changelog needs to clearly indicate why this > > is better/cleaner than embedding the needed info for a single allocation > > and charge function to use. If the callbacks would truly be so different > > that unifying them would be more complex, I think this makes sense. > > Mostly, this boils down to khugepaged having different a allocation > pattern for NUMA/UMA ; the former scans the pages first to determine > the right node, the latter preallocates before scanning. khugepaged > has the luxury on UMA systems of just holding onto a hugepage > indefinitely for the next collapse target. > > For MADV_COLLAPSE, we never preallocate, and so its pattern doesn't > depend on NUMA or UMA configs. Trying to avoid "if (khugepaged) ... > else" casing, defining this as a context-defined operation seemed > appropriate. > > Collapsing both alloc and charging together was mostly a code > cleanliness decision resulting from not wanting to embed a ->gfp() > hook (gfp flags are used both by allocation and memcg charging). > Alternatively, a .gfp member could exist - it would just need to be > refreshed periodically in the khugepaged codepath. > > That all said - let me take another crack at seeing if I can make this > work without the need for a function pointer here. I had a patch that removed UMA allocation, please refer to https://lore.kernel.org/linux-mm/20210817202146.3218-1-shy828301@gmail.com/#t It was not made upstream due to some requests for further cleanup, but unfortunately I haven't got time to look into it yet. If this page were merged, would that make your life easier?