From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.4 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,FSL_HELO_FAKE,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9DDE9C5519F for ; Fri, 20 Nov 2020 05:04:30 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 051B12237B for ; Fri, 20 Nov 2020 05:04:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Wk4JERM5" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 051B12237B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 20D4E6B0036; Fri, 20 Nov 2020 00:04:29 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 19A206B005C; Fri, 20 Nov 2020 00:04:29 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 05E5A6B005D; Fri, 20 Nov 2020 00:04:28 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0157.hostedemail.com [216.40.44.157]) by kanga.kvack.org (Postfix) with ESMTP id BC2086B0036 for ; Fri, 20 Nov 2020 00:04:28 -0500 (EST) Received: from smtpin11.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 2E5F9181AEF23 for ; Fri, 20 Nov 2020 05:04:28 +0000 (UTC) X-FDA: 77503605816.11.owl52_130669d27348 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin11.hostedemail.com (Postfix) with ESMTP id 0FECE180F8B82 for ; Fri, 20 Nov 2020 05:04:28 +0000 (UTC) X-HE-Tag: owl52_130669d27348 X-Filterd-Recvd-Size: 7010 Received: from mail-pg1-f195.google.com (mail-pg1-f195.google.com [209.85.215.195]) by imf14.hostedemail.com (Postfix) with ESMTP for ; Fri, 20 Nov 2020 05:04:27 +0000 (UTC) Received: by mail-pg1-f195.google.com with SMTP id 34so6279635pgp.10 for ; Thu, 19 Nov 2020 21:04:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=VQwpOcD2+t3JbuTg+G3fFZr3cIdjvDbD2vJYrQnBtQU=; b=Wk4JERM5Uf22PLd05xcfiZd95GYLeGiNsmqT+2hVf08I2TakWYkf6ij1szw/cZj2LU Ap3XLp2gKoNqBxgiz+nbXoDMMiPm0Q28cpuRiVPf5Kf16qPO4FX1zk7F4w6gmyzXQbs9 RioUZDa4YBpDhqR05ZJybicTr/AO8xCqYONW6XpkuAI0bYteJdNdklmeN8x20D4WNqjQ UnWiikK9O/xKS0gFtMs6gCnr4T9BOPQoQmCcxYuxINH48Whw3Yuo5ryfjCeg0iQSAqXZ tgLTp1fM5rGVVT56MqmF0ylslr+1ooLxMEML3Pv4cI2uuATSGfAJsVCW7P5JjT1JxRZ6 oIog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to; bh=VQwpOcD2+t3JbuTg+G3fFZr3cIdjvDbD2vJYrQnBtQU=; b=NSO/jfVIgkk3dWOl/1G4KNKcqwBd9GvtuwNIb+CCulLoyM2r0GydaNKxFWTK5Fi5ic rPr8rBAxiYlZsJKi+6vdgxD0E4WECi6Aoo76U+U24y3FwNXQIgYneFCzKeTjWsw4keuo ro1JGEVFcZTcQR64yHlEpiTuaw9imJ+U8t1XEdHrvDJHN9R1TS+NEWn7rqzfesfLbR6S +DbDxQSAKQhmfrHlKtw3rTDf8CSfSv4k34W+0haYuQxjmcCpjmot4sgm0bc8Pm5Ex5bi Uri/GU95K1bnvAy+hD9DQiFBmWv09ysJKinkbYs/aD5URUchnnaFhCsDlAOU5A84YI2u /Lug== X-Gm-Message-State: AOAM533n24/sF+y6quegQCUu3g3c2K2tbAMs1WYIm/5usBLNu0PxhdA+ Ez8zVs11Rwn3Hvgma5Ty6p4= X-Google-Smtp-Source: ABdhPJwJ+exJRYyCKImrposP1ochkmhd46hfB4bpJdDPr8dXKpAnuSvR43nBPgyUn6QZhheBnS1BTg== X-Received: by 2002:a63:389:: with SMTP id 131mr15796760pgd.128.1605848666424; Thu, 19 Nov 2020 21:04:26 -0800 (PST) Received: from google.com ([2620:15c:211:201:7220:84ff:fe09:5e58]) by smtp.gmail.com with ESMTPSA id j16sm1529485pgl.50.2020.11.19.21.04.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Nov 2020 21:04:25 -0800 (PST) Date: Thu, 19 Nov 2020 21:04:23 -0800 From: Minchan Kim To: Zhenhua Huang Cc: vjitta@codeaurora.org, linux-mm , glider@google.com, Dan Williams , broonie@kernel.org, mhiramat@kernel.org, linux-kernel@vger.kernel.org, Andrew Morton , Yogesh Lal , Vinayak Menon , tingwei@codeaurora.org Subject: Re: [PATCH] lib: stackdepot: Add support to configure STACK_HASH_SIZE Message-ID: <20201120050423.GE3113267@google.com> References: <1603372546-27118-1-git-send-email-vjitta@codeaurora.org> <20201119033317.GA5128@codeaurora.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201119033317.GA5128@codeaurora.org> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Thu, Nov 19, 2020 at 11:34:32AM +0800, Zhenhua Huang wrote: > On Wed, Nov 04, 2020 at 07:27:03AM +0800, Minchan Kim wrote: > > 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. > Seems we have other users like kasan, and dma_buf_ref which we introduced. > Also we can't guarantee there will not be any other users for stackdepot, so > it's better we not depend on only page owner? I didn't mean to make it page_owner dependent. What I suggested is just to define kernel parameter for stackdeport hash size so admin could override it at right size when we really need it.