Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1112388pxu; Thu, 17 Dec 2020 02:28:01 -0800 (PST) X-Google-Smtp-Source: ABdhPJyhJmIUm9b1pj2TwJQIBO5raKgjMk0LuqXE+I9HhFNJU6s6JZ/cJx0JgAD9iySD9D1AF/mq X-Received: by 2002:a17:906:eb8d:: with SMTP id mh13mr33826943ejb.299.1608200881408; Thu, 17 Dec 2020 02:28:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608200881; cv=none; d=google.com; s=arc-20160816; b=UdS+O81g6Fugra10E+nEBNSEYMsi1c5oLlOtt2425VVKh8hvN3YG4n0rovcegRx2Wf FjNtRn6t66a+gcze4HLUIZ5aLnkPuMinsMQOGTjr3YXwNXjwbYWhx7EEM2YuVzShM62S A8LBkXlcDhQ/9NVY58PDhSr+npE/9NXKe5K14w63g4sDLFJBzJ211o9havTxgZBhc/f0 WhEV9FxOlY+utFMeKBh2bucLbrpX/S2/QonFlL7dtZ4mLtOBXvEtA8t1VH2oYxAdo+9P +nAhuqn8jCXIGooU24VfWsgo+2lqp6VZ26SdJh36r/Bx/7xT5gqzgJyYFhSt0mtWl6LX N3DQ== 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=7dPMjrwUyVJ0SctrZbQ7QI+UYy17WeAuqUz3oRrGTfU=; b=w/uu5sWD9pE07irVObzKYwhy4r2xV37AlvkayyT6YRVJjmipIBSkN1jtVtoO81ebPO VQeYSaQ5kuEN2VwoWmbHHVjDgCw2wCSfrrvMZfSa8h0uxeHhn6hZ2Z5mjvvf+ggN6hn5 7EQp2oEEmIKHlHNmRy+zZNBhZHHKhtZq9xb/TA+SU6s5zqvCNe2XGuMvyptLlNucSjOs xYmtfEUeWkjZBdUdp/w7JZ7YwayXqqVkRoRZG9cabRvnY6l6XK6yiqGpJ4LGkcUITnXT 9LP5ktLKEl/PLy2zRTejNcNb2U+dLpuE9Vx4eWurEKNd/Zj4tZJ9xuUivAk4xesnVls3 E6dw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="YjBwGZ/Z"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s15si2384622ejb.157.2020.12.17.02.27.37; Thu, 17 Dec 2020 02:28:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="YjBwGZ/Z"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726580AbgLQK0v (ORCPT + 99 others); Thu, 17 Dec 2020 05:26:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55234 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725950AbgLQK0u (ORCPT ); Thu, 17 Dec 2020 05:26:50 -0500 Received: from mail-qv1-xf2b.google.com (mail-qv1-xf2b.google.com [IPv6:2607:f8b0:4864:20::f2b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 919DEC061794 for ; Thu, 17 Dec 2020 02:26:10 -0800 (PST) Received: by mail-qv1-xf2b.google.com with SMTP id bd6so12999011qvb.9 for ; Thu, 17 Dec 2020 02:26:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=7dPMjrwUyVJ0SctrZbQ7QI+UYy17WeAuqUz3oRrGTfU=; b=YjBwGZ/ZowFcu1nU6IrRb8tl/pkkMdBn8V1gJ42p94EX1pGmEurG735ueO/5zZcpVQ a562shO7G5LPjfRei2CoR6R4JzTQmGO1mpAl81SP/lbx9sLBs7BGrHqWEoigd9y4gTc1 u/BfUw6eVyPKuFVpkjvwHfKhLgS3L0TCD+W5YU0/YMwiHLXlfp+TTVPNsPJg3ZLsJmP/ Xn+fqGt+kAlapzniITfUbYAU7VYLbqn7LP3x0ADwfala5zJ17IOsRipH5zsddhPAMMr5 ebPlWHJT2vpcYkJ9MitZhe1NWm6Jp2laoi24TD3icAX5DxauBSzf6bkvekMtNUOE0J4U WvOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=7dPMjrwUyVJ0SctrZbQ7QI+UYy17WeAuqUz3oRrGTfU=; b=RZJPIRavatFvOVv1X+n87WoJj+Qy6JXyAx96zJtjnghG7XvAgs48cOMuBMJcQ0IrKf /Dppnb/aVzAabigbubnAmqhIiRgmS9ioJqi5tbTsZMeB66BlDtKibwQ/u4oR/5dVIYqL NurOxO5QCFW6Caf0yzyMElmYncXgwb3AJDcmimu7bSDztqjWX+7nyerBUGhtwV7jl/bq G7vJ9jk4Xk0nkDdiQTlxzKBDy7jhA2dyK9r6+bv/vwO+qYdBpWPdVkCNt18oG49fL0Sx pvNMZFgYA/dF6KUglcVJqq6M8z/ao4iVZ7erONo13ALF2T/jdGD6aYeqfoAMobT6GHLC B10w== X-Gm-Message-State: AOAM530Mi0Tpr+WmEkkVv1U3iDI2dNQ9MZR6Xp07rNEY7zYMByKYuEwo 3fwdq+BFso/e05cOIIbL7QIZk/z7IXs4jE1Hu5ftgg== X-Received: by 2002:a0c:b20d:: with SMTP id x13mr48172339qvd.18.1608200769366; Thu, 17 Dec 2020 02:26:09 -0800 (PST) MIME-Version: 1.0 References: <1607576401-25609-1-git-send-email-vjitta@codeaurora.org> In-Reply-To: <1607576401-25609-1-git-send-email-vjitta@codeaurora.org> From: Dmitry Vyukov Date: Thu, 17 Dec 2020 11:25:57 +0100 Message-ID: Subject: Re: [PATCH v3] lib: stackdepot: Add support to configure STACK_HASH_SIZE To: Vijayanand Jitta , kasan-dev Cc: Minchan Kim , Vincenzo Frascino , Alexander Potapenko , Dan Williams , Mark Brown , Masami Hiramatsu , LKML , Andrew Morton , Andrey Konovalov , qcai@redhat.com, ylal@codeaurora.org, vinmenon@codeaurora.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Dec 10, 2020 at 6:04 AM wrote: > > From: Yogesh Lal > > Add a kernel parameter stack_hash_order to configure STACK_HASH_SIZE. > > Aim is to have configurable value for STACK_HASH_SIZE, so that one > can configure it depending on usecase there by reducing the static > memory overhead. > > One example is of Page Owner, default value of STACK_HASH_SIZE lead > stack depot to consume 8MB of static memory. Making it configurable > and use lower value helps to enable features like CONFIG_PAGE_OWNER > without any significant overhead. > > Suggested-by: Minchan Kim > Signed-off-by: Yogesh Lal > Signed-off-by: Vijayanand Jitta > --- > lib/stackdepot.c | 31 +++++++++++++++++++++++++++---- > 1 file changed, 27 insertions(+), 4 deletions(-) > > diff --git a/lib/stackdepot.c b/lib/stackdepot.c > index 81c69c0..e0eebfd 100644 > --- a/lib/stackdepot.c > +++ b/lib/stackdepot.c > @@ -30,6 +30,7 @@ > #include > #include > #include > +#include > > #define DEPOT_STACK_BITS (sizeof(depot_stack_handle_t) * 8) > > @@ -141,14 +142,36 @@ static struct stack_record *depot_alloc_stack(unsigned long *entries, int size, > return stack; > } > > -#define STACK_HASH_ORDER 20 > -#define STACK_HASH_SIZE (1L << STACK_HASH_ORDER) > +#define MAX_STACK_HASH_ORDER 20 > +#define MAX_STACK_HASH_SIZE (1L << MAX_STACK_HASH_ORDER) > +#define STACK_HASH_SIZE (1L << stack_hash_order) > #define STACK_HASH_MASK (STACK_HASH_SIZE - 1) > #define STACK_HASH_SEED 0x9747b28c > > -static struct stack_record *stack_table[STACK_HASH_SIZE] = { > - [0 ... STACK_HASH_SIZE - 1] = NULL > +static unsigned int stack_hash_order = 20; > +static struct stack_record *stack_table_def[MAX_STACK_HASH_SIZE] __initdata = { > + [0 ... MAX_STACK_HASH_SIZE - 1] = NULL > }; > +static struct stack_record **stack_table __refdata = stack_table_def; > + > +static int __init setup_stack_hash_order(char *str) > +{ > + kstrtouint(str, 0, &stack_hash_order); > + if (stack_hash_order > MAX_STACK_HASH_ORDER) > + stack_hash_order = MAX_STACK_HASH_ORDER; > + return 0; > +} > +early_param("stack_hash_order", setup_stack_hash_order); > + > +static int __init init_stackdepot(void) > +{ > + size_t size = (STACK_HASH_SIZE * sizeof(struct stack_record *)); > + > + stack_table = vmalloc(size); > + memcpy(stack_table, stack_table_def, size); Can interrupts happen at this point in time? If yes, they can use/modify stack_table_def concurrently. > + return 0; > +} > +early_initcall(init_stackdepot); > > /* Calculate hash for a stack */ > static inline u32 hash_stack(unsigned long *entries, unsigned int size) > -- > 2.7.4 > QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation