Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp411538pxu; Thu, 26 Nov 2020 01:41:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJxz2bPstIf4hlS7EZ7J/Ic7LjUDcKSk5CWgfnNx9aLLI113JWQE4Mz4YyWjwoEotaNuq1iJ X-Received: by 2002:a17:906:27d1:: with SMTP id k17mr654689ejc.325.1606383706927; Thu, 26 Nov 2020 01:41:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606383706; cv=none; d=google.com; s=arc-20160816; b=BQshef58R8RTxM+1ODdbSGI4v1ofR+EBdT33qgKrmLKlFHtlzFqKJp5GiRmmMJFZY8 sjs46Z3OxLoJ88Q0Abr07oeMCqPWJxjNDABbWRluRNoY27yBs3RGo1ioW5aGrFfmSMpv Gzrh1DCyMNc/tVEKgoP5tGcoiChpXEDGAfQa/PgzdKadb6DanmTvPjX7FC+u+zIdjXfx MCOQKjyS1h9UAsbv8+xyVVnc/j9FELFbwx4+jQIEerYs9MAZj01Mv59mMV4YEvJq+c40 QXSCy1KKSMkr+0id6LA0CsQTD0BMdlS+L/tZ8Y1wK7OL+fY8jk6GZLzVdVIy/u1s6e7t 4P+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from:dmarc-filter :sender:dkim-signature; bh=JSPVZUJfrhFGcM62y2MiWrkRMono5giHdlPyGnNXdec=; b=r6rs/88835JbSF57xsEgCbBnvxG9r1A+UXj6tk1Fzth2FHxtOdtJzOVZOM+lF5UpB/ Lq+LVFHBxJBxCPZn7EVGhwWp5KMFxrvTttE2VaesavtG2l2VAcDWr4XLrnjGhtzrKYTZ 2eYxl/ty8K+4upSWm9YGszFlj1mPMJC884EA0ZmpdsJemlmVWI54Jbavs3PIQsbCLl97 3KaGws9NPFR98bc6xW1L/h6kSP4Em7mCp8KPhumNoxdGgrsAmE9Mngni0///0PNnEvll 6hK8ODTNTumCtx9MEika/XpHJBFTTrR//RnZwmsqn6qh8KEzjahGHcCiqPrBTCsHqB6r 1t+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b="u3O1L+/H"; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x9si860603ejc.623.2020.11.26.01.41.24; Thu, 26 Nov 2020 01:41:46 -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=@mg.codeaurora.org header.s=smtp header.b="u3O1L+/H"; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732135AbgKZEoR (ORCPT + 99 others); Wed, 25 Nov 2020 23:44:17 -0500 Received: from m42-4.mailgun.net ([69.72.42.4]:53520 "EHLO m42-4.mailgun.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731686AbgKZEoR (ORCPT ); Wed, 25 Nov 2020 23:44:17 -0500 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1606365856; h=Message-Id: Date: Subject: Cc: To: From: Sender; bh=JSPVZUJfrhFGcM62y2MiWrkRMono5giHdlPyGnNXdec=; b=u3O1L+/Hpo7znghDeZm3a231kbg9Yn0+GJQQmpbz67QXj8A//tEJg4tlNFETzQLJHxYKM5vK 32pPbJFLgCoeaf5KJPMuGWSG3xal75rhMnm4p/IdgZAACP7646BrxJvCDyfLaTTZHimHHRti Iewt25Kic+HWw2ZtPsuzj+84i3A= X-Mailgun-Sending-Ip: 69.72.42.4 X-Mailgun-Sid: WyI0MWYwYSIsICJsaW51eC1rZXJuZWxAdmdlci5rZXJuZWwub3JnIiwgImJlOWU0YSJd Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n08.prod.us-east-1.postgun.com with SMTP id 5fbf329e1b731a5d9c8d8c27 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Thu, 26 Nov 2020 04:44:14 GMT Sender: vjitta=codeaurora.org@mg.codeaurora.org Received: by smtp.codeaurora.org (Postfix, from userid 1001) id AD5BEC43464; Thu, 26 Nov 2020 04:44:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=ALL_TRUSTED,BAYES_00,SPF_FAIL, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from vjitta-linux.qualcomm.com (unknown [202.46.22.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: vjitta) by smtp.codeaurora.org (Postfix) with ESMTPSA id BF0BCC433ED; Thu, 26 Nov 2020 04:44:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org BF0BCC433ED Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=fail smtp.mailfrom=vjitta@codeaurora.org From: vjitta@codeaurora.org To: minchan@kernel.org, glider@google.com, dan.j.williams@intel.com, broonie@kernel.org, mhiramat@kernel.org Cc: linux-kernel@vger.kernel.org, akpm@linux-foundation.org, vjitta@codeaurora.org, ylal@codeaurora.org, vinmenon@codeaurora.org Subject: [PATCH v2] lib: stackdepot: Add support to configure STACK_HASH_SIZE Date: Thu, 26 Nov 2020 10:13:55 +0530 Message-Id: <1606365835-3242-1-git-send-email-vjitta@codeaurora.org> X-Mailer: git-send-email 2.7.4 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/lib/stackdepot.c b/lib/stackdepot.c index 81c69c0..ce53598 100644 --- a/lib/stackdepot.c +++ b/lib/stackdepot.c @@ -141,14 +141,31 @@ 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) +static unsigned int stack_hash_order = 20; +#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 struct stack_record **stack_table; + +static int __init setup_stack_hash_order(char *str) +{ + kstrtouint(str, 0, &stack_hash_order); + return 0; +} +early_param("stack_hash_order", setup_stack_hash_order); + +static int __init init_stackdepot(void) +{ + int i; + + stack_table = kvmalloc(sizeof(struct stack_record *) * STACK_HASH_SIZE, GFP_KERNEL); + for (i = 0; i < STACK_HASH_SIZE; i++) + stack_table[i] = NULL; + return 0; +} + +early_initcall(init_stackdepot); /* Calculate hash for a stack */ static inline u32 hash_stack(unsigned long *entries, unsigned int size) -- QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation 2.7.4