Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp958819pxu; Fri, 11 Dec 2020 20:17:25 -0800 (PST) X-Google-Smtp-Source: ABdhPJyegOhSGZqVbkiqG4PNp5vrXPW/pPG85RXWz97dOgDKX7m6MTP9IeautctweSfo6jc9lbGf X-Received: by 2002:aa7:d750:: with SMTP id a16mr15287349eds.252.1607746645316; Fri, 11 Dec 2020 20:17:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607746645; cv=none; d=google.com; s=arc-20160816; b=gmTNMg0Ps3BKQiwCN3oOUtI2KWSRyDTxKvffY3i/KdUYxmZKJEz8+Z8oguohQMET2m 547nbkBSodIORc5Z0WJQKB9aHkizj3Fqo2a9WDix9HOFezvGozE9+gUGElFlAq4OCoON qSjxm9J0DUWn4+Q6zC8IZtkCGSyqPRZXbBLectSGjaATYUb0ILblTVareRqGsBMi6HMg P6YajuslFdFVDyLJ4CE1DGi+jukT9udk6Y2f822eKASNVCXSxKDFnJxuP+LEI98dOuw3 tMmIwKBoxY9lz8qm4x6r7UoMR3GNgxSdTbjlW1I2LcHuEM6U+dYS7ZS0f9a/SDQu0p8o AWSA== 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=5Dxbid0Ia6yZGyb4lUSC6Gr0oUo82+QX8jC8lSF5YfY=; b=sG0xI/aSxDEpYkN3eaKg/UoTCN97aNxiLbIXoxIoFSD1KyrJL/2T8LEsvAtvZjwSn5 Bm4zgPvXkhwtp2yLZaBcSkVh4JBfTvWkaf0CLiKn2/rb9SdzELVmOGhfgB3Ygzx+6Jot jPsrQIi6XWjq8lB16edQL0w2fRv1ZfOuXrkeH6DQWh6bYychBcntWnA2eY52WhBJM6I4 04i/1LjD3CCARqJvLYNaNQlyRTgnHo6TqrXH6/2azGyanxMOW7cuFimpgDs0sJDjCwcC JCks7R5Es5dXHTDYdwJ2ylL+IxzD+xizW8P22ph4o/2PChyBVLvYqZ1LqtEXE6xtxejT XqHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=RmNXu9p6; 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 mm28si5551036ejb.138.2020.12.11.20.17.03; Fri, 11 Dec 2020 20:17:25 -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=RmNXu9p6; 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 S2392076AbgLKIha (ORCPT + 99 others); Fri, 11 Dec 2020 03:37:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46718 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391957AbgLKIg5 (ORCPT ); Fri, 11 Dec 2020 03:36:57 -0500 Received: from mail-qk1-x743.google.com (mail-qk1-x743.google.com [IPv6:2607:f8b0:4864:20::743]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 30CE7C0613CF for ; Fri, 11 Dec 2020 00:36:17 -0800 (PST) Received: by mail-qk1-x743.google.com with SMTP id 143so7708552qke.10 for ; Fri, 11 Dec 2020 00:36:17 -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=5Dxbid0Ia6yZGyb4lUSC6Gr0oUo82+QX8jC8lSF5YfY=; b=RmNXu9p6jAeFq2XsLx0cM4WWcOpYs72EIzntZ8V0U7pQKYaFhljgGl1ZYntgRgxmkl +hMDtreDljBHM7rv9TwyQauj+AUAhbCDFcx8E67OussK9I7vtZ479QtJbQJcykg4kAjv xntVedjm+hzKLQV3cFed3l1pKT2hW+23F1aRHbWLyZ2t0Kz9XsvDkCa9AcerXytFHCb1 MCHNnDpUuqG0JP5bR9mE9/e0FIPBVfzD1dnnXG7GR1vaNkd2CVcS5yUdkuJwjeboQpq2 MEqTBUtv64XvRIpXMaqzZG/CUkdB/68x54LGgfoFIA54Yn+t3ac381syXynoRu6Rtefu P2RA== 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=5Dxbid0Ia6yZGyb4lUSC6Gr0oUo82+QX8jC8lSF5YfY=; b=YGh/FO4o8H4fjObpfBtkEpZvHDOnloMTwshku1fbo0YrF2xrtEQL779k78Fk8uiIcz tozCn2Oj0liic88blDR3EYTx3pszf0ys63NPQUCSWf0nEJJbONyMNLlQUP0mUrlsA6aH jHKZfqTyynsIKi+OZZKjgTXyMpLXrQ59y0CF4FJKrGiXdQ3m2wHB1ZCK2BnjzQMlv8E3 wMLuju54Cg+eHhmfnDbj6VGYFykPAZAmZoQ/SdD1181tWV7e9Vt22jk6053rEvj1Evpe fwWy3ZM8YmX0ZzgRSERCWCSGvIu08G8aBNRYABooOgsWH3cVKoAR2KlH5zOhigrhalHy LXdw== X-Gm-Message-State: AOAM533PtCYHVB2SS27xH63yXv+FT0VpgoZ9yI/3OsaQj2wbmS+h3o7i aqWer1AEql+keuu6kvRJVQRlkFE8fuPZmgejYu3X8g== X-Received: by 2002:a37:45d2:: with SMTP id s201mr14328842qka.326.1607675776124; Fri, 11 Dec 2020 00:36:16 -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: Alexander Potapenko Date: Fri, 11 Dec 2020 09:36:04 +0100 Message-ID: Subject: Re: [PATCH v3] lib: stackdepot: Add support to configure STACK_HASH_SIZE To: vjitta@codeaurora.org Cc: Minchan Kim , Vincenzo Frascino , dan.j.williams@intel.com, broonie@kernel.org, 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:01 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. Can we go with a static CONFIG_ parameter instead? Guess most users won't bother changing the default anyway, and for CONFIG_PAGE_OWNER users changing the size at boot time is not strictly needed. > -static struct stack_record *stack_table[STACK_HASH_SIZE] = { > - [0 ... STACK_HASH_SIZE - 1] = NULL > +static unsigned int stack_hash_order = 20; Please initialize with MAX_STACK_HASH_ORDER instead. > +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); Looks like you are assuming stack_table_def already contains some data by this point. But if STACK_HASH_SIZE shrinks this memcpy() above will just copy some part of the table, whereas the rest will be lost. We'll need to: - either explicitly decide we can afford losing this data (no idea how bad this can potentially be), - or disallow storing anything prior to full stackdepot initialization (then we don't need stack_table_def), - or carefully move all entries to the first part of the table. Alex