Received: by 2002:a05:6358:16cd:b0:dc:6189:e246 with SMTP id r13csp1425876rwl; Fri, 4 Nov 2022 13:54:49 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5dI3i9PBY0TNsN4rrdHppQB4gLH5UU4XkCR0YAMD2VUsPKdScfUVQ9dFfEupxzmd0gLHnj X-Received: by 2002:a63:fa4f:0:b0:46f:d2d5:ecd with SMTP id g15-20020a63fa4f000000b0046fd2d50ecdmr21766758pgk.514.1667595288929; Fri, 04 Nov 2022 13:54:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667595288; cv=none; d=google.com; s=arc-20160816; b=I+c1vG+TdzrUgp3Xucntyhk5DVI+worC/YUNVePwR4D4aJsgUMp9LfNSJiAhd3hP+I 0lq+Xgq0bqRFo/yST3eRqHECRKo4R+ADIwltISewhcABTcgTHCL3xhrF2a0OyGMGPOmn s2haUmQloMKyRjCGCzjsQUZKw2iBkoRWpHVlh3eH7uxsm0dGUUiJPmGDSKddQKEQRduh 0IXsx2kkLwh0Idxytri9tadTiJnu4RVobgyFSL9P8qJ96f1hZqV6BvltpSl0d34GQqj1 ZeThuF5zR6EbOLVUFODcWycNooCiqHkFqidLWs36gnnFmZWi98hn2RMA9Oc32to7qtpl TABA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=f/Mzrdh822ICr7apu8JxzHNEOBsO25I9fYrSs9HSUig=; b=FcElhwYFDvMk/yO9+nBVKU/p64svy+aMx3m1ETyLaZcHthOgTbOhYeJxTOlXTgl8Mz s9IOb7+UYPzoXCrhNx3FPb4jmjp6i8LNGOVUD66j0V1Yx7O2b3AbdIhFI+U+/iSeBL2X JP1QUDfSHbJD0J33B2aCtp9VywICF6r1gkHsdNmOlpphQ7AXkcW+2yiXsri9157lOCnB b3dhCWzyAM8BH0SDskAvq04Ei4748KqIMhRoDSBWMz0DVKCB5Y1zjNSG4f77W58BtHc4 CTCaVKDA8XrJHNBjbfhTDr4m37gN+JfbeODJfUGHxV//qHS0YZsN/4F4ztrpfOxVxz90 anxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="M/cVmBv5"; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j190-20020a638bc7000000b0046ec7beb578si563767pge.94.2022.11.04.13.54.36; Fri, 04 Nov 2022 13:54:48 -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=@gmail.com header.s=20210112 header.b="M/cVmBv5"; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229766AbiKDUlK (ORCPT + 97 others); Fri, 4 Nov 2022 16:41:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39740 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229574AbiKDUlA (ORCPT ); Fri, 4 Nov 2022 16:41:00 -0400 Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4947845ED2 for ; Fri, 4 Nov 2022 13:40:59 -0700 (PDT) Received: by mail-pj1-x1030.google.com with SMTP id d59-20020a17090a6f4100b00213202d77e1so9278978pjk.2 for ; Fri, 04 Nov 2022 13:40:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=f/Mzrdh822ICr7apu8JxzHNEOBsO25I9fYrSs9HSUig=; b=M/cVmBv5EUeUoHlgfUMn062PCK/nUCt7P5kcuK24V2c3qSGOkDGOoy2HaI3BCo38sl 8ZQ91fmCQyWPmu4Lfk74NSGZmHfPS/INBakCG6hKjaLBI0hVZL7sAWIMAl64nzJlm2Il 5e7SJcpdrh3KsfgxcXdxb8GgVfOiPxV4Yjc5PKCxixHsx+jDhJjf2oVzgvV90oSTxzf0 pWrAA8CVh6QI+fOU5YIUICzgwOURHv0yRCxnZayfd7ELVH7HkbC3gLtNGx8Bec/RIMs9 bsa6R77BbT62r9O+r70Zk6ZogFHxgZEupF3JAqWnJXz766AxEWlvaMXlkhHweEaXDQx+ 8olQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=f/Mzrdh822ICr7apu8JxzHNEOBsO25I9fYrSs9HSUig=; b=SPgknbPirUGMhUiPVNh+WNoJ8utAcnRPAo9GCYXMZc7sjYYf4FmnJ+qr7Y15UsaZT2 fNVduBZMn8YdMmS/gjIi7g5ZrVnFhQ4055jOaOza7FOqBrSw6d1+96suNKfp/W8VeTGx klwBJNmDr2JPfYrh/kPRBf7IE67HXegBCzkF1xU7PQI7EVnom+WEm7ucbDuUMVheA37+ 94PZk9UGeRZnET/SmMay2jWKlf0etcC0EmqdwNIK3tdA2fARKcQnSr8YySneKj6or7Im pVWa/1BzoHhqfC7f89H6jKMS5sOBa2DCx0jVXLaAxbNYccJzO7BddBIi92zpKuz1YEWB B3Ow== X-Gm-Message-State: ACrzQf1YEhUOHfdRXy1V7Pk+6kKlPWAg/IIraDVgGTUViIcWvogsSkfL fSlwWteBl6y1u+GnmUtozY+WGan8NsTIHwX8IpM= X-Received: by 2002:a17:902:d512:b0:181:f1f4:fcb4 with SMTP id b18-20020a170902d51200b00181f1f4fcb4mr37749838plg.102.1667594458762; Fri, 04 Nov 2022 13:40:58 -0700 (PDT) MIME-Version: 1.0 References: <20221103213641.7296-1-shy828301@gmail.com> In-Reply-To: From: Yang Shi Date: Fri, 4 Nov 2022 13:40:46 -0700 Message-ID: Subject: Re: [v2 PATCH 1/2] mm: khugepaged: allow page allocation fallback to eligible nodes To: Michal Hocko Cc: zokeefe@google.com, akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS 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 On Fri, Nov 4, 2022 at 12:55 PM Michal Hocko wrote: > > On Fri 04-11-22 10:37:39, Yang Shi wrote: > > On Fri, Nov 4, 2022 at 1:32 AM Michal Hocko wrote: > > > > > > On Thu 03-11-22 14:36:40, Yang Shi wrote: > > > [...] > > > > So use nodemask to record the nodes which have the same hit record, the > > > > hugepage allocation could fallback to those nodes. And remove > > > > __GFP_THISNODE since it does disallow fallback. And if nodemask is > > > > empty (no node is set), it means there is one single node has the most > > > > hist record, the nodemask approach actually behaves like __GFP_THISNODE. > > > > > > > > Reported-by: syzbot+0044b22d177870ee974f@syzkaller.appspotmail.com > > > > Suggested-by: Zach O'Keefe > > > > Suggested-by: Michal Hocko > > > > Signed-off-by: Yang Shi > > > > --- > > > > mm/khugepaged.c | 32 ++++++++++++++------------------ > > > > 1 file changed, 14 insertions(+), 18 deletions(-) > > > > > > > > diff --git a/mm/khugepaged.c b/mm/khugepaged.c > > > > index ea0d186bc9d4..572ce7dbf4b0 100644 > > > > --- a/mm/khugepaged.c > > > > +++ b/mm/khugepaged.c > > > > @@ -97,8 +97,8 @@ struct collapse_control { > > > > /* Num pages scanned per node */ > > > > u32 node_load[MAX_NUMNODES]; > > > > > > > > - /* Last target selected in hpage_collapse_find_target_node() */ > > > > - int last_target_node; > > > > + /* nodemask for allocation fallback */ > > > > + nodemask_t alloc_nmask; > > > > > > This will eat another 1k on the stack on most configurations > > > (NODE_SHIFT=10). Along with 4k of node_load this is quite a lot even > > > on shallow call chains like madvise resp. khugepaged. I would just > > > add a follow up patch which changes both node_load and alloc_nmask to > > > dynamically allocated objects. > > > > The collapse_control is allocated by kmalloc dynamically for > > MADV_COLLAPSE path, and defined as a global variable for khugepaged > > (khugepaged_collapse_control). So it is not on stack. > > Dang, I must have been blind because I _think_ I have seen it as a local > stack defined. Maybe I just implicitly put that to the same bucket as > othe $foo_control (e.g. scan_control, oom_control etc) which leave on the > stack usually. Sorry about the confusion. Sorry for the noise. It doesn't matter. It was not put on the stack due to its size when Zach was adding MADV_COLLAPSE. > > Acked-by: Michal Hocko Thanks. > -- > Michal Hocko > SUSE Labs