Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp885480pxb; Tue, 3 Nov 2020 15:32:49 -0800 (PST) X-Google-Smtp-Source: ABdhPJyTIh7GTafSSPsPJMpjCW+ZbcgVpjzfhexGV+BOy6M6wzJivtsJV6vIg08SNyrnoldQpddu X-Received: by 2002:a17:906:6409:: with SMTP id d9mr22474706ejm.344.1604446368993; Tue, 03 Nov 2020 15:32:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604446368; cv=none; d=google.com; s=arc-20160816; b=lSWa0+nyREfY8e3fv5aVhrV2WLJHcCuzbtCo9e+HccgZTNKSjaobnjMpv7sA2sXnKi BtK+9gCVlkI4/tmL9vg4CCZhJ9wV1Phut4qdXzx5o9DfJP/H3rQlI6o/yzj+EC2EGet8 NdGoMojckZA7+qPr4ycPHzMPSwTB2SPdk5WjeA9VW4n/CLTg6Pd3J+wIjKqPGhMe3V/M zi4H7C6dwamrwir6TUmVqGnvO8nTT/PQmtaHAFkg3qv4VOI3NCWvfYBdkzoGCNO5t1mt TYdHUbhVD6fIR463I5znA1ylaUULdW6AtqiuxTF3HeCKRS2hthme9nDNec45G62s4D2M XzOg== 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; bh=nleQTGqvyY37bDvPtiFwPNAyFfPRKwZA1dXnS2tI+5Q=; b=nK47WCiWIHtgPkkXIOXygBxfPvxsV3H2fPeY/L41TW4oAjPAmesGDSDjHa6KKlvA2L biJ8Rh4Z34vXNuN81iTg/ibWmeDcFP2JZsguWjthG8+TmOXUu/gbB0XbKyl3J1COdUfE a6Qs92V1E/dh7H2tVrWDJ6v703WNiGk/rkspnzdRqRpNTnSM79lCKIKo3EoieYBMiWSz EqVPTIuaMuHS323VZstJl0UVyUqTk86T25XW1ttN3M5qfP7H3VMgBa89IM5xWgLK4ESw EX7F3NE60kfv1ztkXVaeL7tJLXVwTDiz6vCzdazjZTYFx8jPaDVc8gSPwhowX8T53baY hMVg== ARC-Authentication-Results: i=1; mx.google.com; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d13si245602ejc.458.2020.11.03.15.32.26; Tue, 03 Nov 2020 15:32:48 -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; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729346AbgKCX1U (ORCPT + 99 others); Tue, 3 Nov 2020 18:27:20 -0500 Received: from mail-wm1-f66.google.com ([209.85.128.66]:38889 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727688AbgKCX1U (ORCPT ); Tue, 3 Nov 2020 18:27:20 -0500 Received: by mail-wm1-f66.google.com with SMTP id h62so783112wme.3 for ; Tue, 03 Nov 2020 15:27:19 -0800 (PST) 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=nleQTGqvyY37bDvPtiFwPNAyFfPRKwZA1dXnS2tI+5Q=; b=qHEY/G07qTQ0SLqSVJ2/T1c/Lshc7PlMUnzZg5OR7hVlkXp4Yea6ZNQLIDuIzgIG+9 WlP7VtBdHhVVT7YiBfvA1UEMO+jGRFEkdR1z8bSaKckS8lzaERsGxt+sR1JKxVDeWl/1 PZcp3rzUOJaWTxK1QvwjNjXoUzYCADKeB6TXwTvH7sNC6gOtVxqqGIQzg5K12wYCQuI2 JzO4jAKxavESAzbsZ8fXfZ3VXgJNnpe5579H7aeNwI0gJoBAQ2jpGKloKjbC4Xlee1o7 B6hO9iNHlk/Gn/TIBcKvUXxlvO8fvu4jD6PQT8shbcEdCDsEuvujmTx/KosznVuaHlks jj7A== X-Gm-Message-State: AOAM531ZdISkQWYsGfCWB0ttTIDwVzb7Z3arICmlev9xCdiprkwjyEUe /mHwP3sRR7/wetGoKwDI4HzKG8POzZM2w4dS9CU= X-Received: by 2002:a1c:b487:: with SMTP id d129mr1608687wmf.38.1604446038443; Tue, 03 Nov 2020 15:27:18 -0800 (PST) MIME-Version: 1.0 References: <1603372546-27118-1-git-send-email-vjitta@codeaurora.org> In-Reply-To: <1603372546-27118-1-git-send-email-vjitta@codeaurora.org> From: Minchan Kim Date: Tue, 3 Nov 2020 15:27:03 -0800 Message-ID: Subject: Re: [PATCH] lib: stackdepot: Add support to configure STACK_HASH_SIZE To: vjitta@codeaurora.org, linux-mm Cc: glider@google.com, Dan Williams , broonie@kernel.org, mhiramat@kernel.org, "linux-kernel@vger.kernel.org" , Andrew Morton , Yogesh Lal , Vinayak Menon Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Sorry if this mail corrupts the mail thread or had heavy mangling since I lost this mail from my mailbox so I am sending this mail by web gmail. On Thu, Oct 22, 2020 at 10:18 AM wrote: > > From: Yogesh Lal > > Use STACK_HASH_ORDER_SHIFT to configure STACK_HASH_SIZE. > > Aim is to have configurable value for STACK_HASH_SIZE, > so depend on use case one can configure it. > > 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. > > Signed-off-by: Yogesh Lal > Signed-off-by: Vinayak Menon > Signed-off-by: Vijayanand Jitta > --- > lib/Kconfig | 9 +++++++++ > lib/stackdepot.c | 3 +-- > 2 files changed, 10 insertions(+), 2 deletions(-) > > diff --git a/lib/Kconfig b/lib/Kconfig > index 18d76b6..b3f8259 100644 > --- a/lib/Kconfig > +++ b/lib/Kconfig > @@ -651,6 +651,15 @@ config STACKDEPOT > bool > select STACKTRACE > > +config STACK_HASH_ORDER_SHIFT > + int "stack depot hash size (12 => 4KB, 20 => 1024KB)" > + range 12 20 > + default 20 > + depends on STACKDEPOT > + help > + Select the hash size as a power of 2 for the stackdepot hash table. > + Choose a lower value to reduce the memory impact. > + > config SBITMAP > bool > > diff --git a/lib/stackdepot.c b/lib/stackdepot.c > index 2caffc6..413c20b 100644 > --- a/lib/stackdepot.c > +++ b/lib/stackdepot.c > @@ -142,8 +142,7 @@ 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 STACK_HASH_SIZE (1L << CONFIG_STACK_HASH_ORDER_SHIFT) > #define STACK_HASH_MASK (STACK_HASH_SIZE - 1) > #define STACK_HASH_SEED 0x9747b28c > > -- > QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation > 2.7.4 > 1. When we don't use page_owner, we don't want to waste any memory for stackdepot hash array. 2. When we use page_owner, we want to have reasonable stackdeport hash array With this configuration, it couldn't meet since we always need to reserve a reasonable size for the array. Can't we make the hash size as a kernel parameter? With it, we could use it like this. 1. page_owner=off, stackdepot_stack_hash=0 -> no more wasted memory when we don't use page_owner 2. page_owner=on, stackdepot_stack_hash=8M -> reasonable hash size when we use page_owner. -- Kind regards, Minchan Kim