Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp4058923pxu; Mon, 21 Dec 2020 03:16:52 -0800 (PST) X-Google-Smtp-Source: ABdhPJwpaEPUiMKnY6T2JbTnBofzZUDiS7jUsjJqQ0LhGf8HoZ6CnkwP75zZ0gTbJm+fk8kcclY/ X-Received: by 2002:a17:906:6d14:: with SMTP id m20mr14659952ejr.3.1608549412580; Mon, 21 Dec 2020 03:16:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608549412; cv=none; d=google.com; s=arc-20160816; b=ueRzVGAcc2u3nX8eVy4Fiv+9D6GSK4Jp6LvwCPNuPeYPz8v9D3LOV8J0x3yfNS1knv Hu1AiEEJaQEB2PFRzi+gItB5xHq09cQsxArdcoWj8F4qOP+fhU2s+fy0ccuFXvOzg0Mm 2/i0x7xYWqc+Ojs6XXk+dU9e6P1F6jlbImwPPJhVOj+y0gkLtxBGv/tGwDySFOrWOob7 eFUH2JD5m8jsu5wAp0fthGODzmTLO4sPUW+d8wqDIUJmdXpsx4/2rZaGkw/q1OHVAYu7 Cwe/ppwkCnAPQuk118P2aOJST4iLedatmRg5q/AzNmcsgoq0dawm4oH6cZwoyDSV8E1j LCIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:references:cc :to:from:subject:dmarc-filter:sender:dkim-signature; bh=Y4CbVjRa9PKJTQWOMPwKVt5xzYyrbkTeQUsDXoEzPFU=; b=CVGMEh39uUbHI7+rqvCzeR5/52DWG0zdwUKc0OyoOMTRDF0fE57WmbP52fD2bIZHZc cQZFyFT0KCv2LI6SCSZAC1lQRBrDqh/tZl4YGWY++bnDeCfC27IjW6kOjL+9IHkSQfp/ RPScZNGyEOLq9pF+eszowScehxbrwUgwvfraB4Ov4g14fWmJ+55kU83IYuBOFZh97RBh lk+l+pWqqlvx/bjQj9s5o4AAx+dgiPYUfAdn0Rv6HZJbNlAH2ShUdb2WeUlekG72vOMK cpSjLxa513/1Qd0CMZ29ObAEOWAUWQHBjcQuduZSCQRyoaZPvC4NkYkIafpSHpowxwVV 09RA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=A9dIibCS; 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 s16si10149763edx.443.2020.12.21.03.16.30; Mon, 21 Dec 2020 03:16:52 -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=A9dIibCS; 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 S1726290AbgLULPx (ORCPT + 99 others); Mon, 21 Dec 2020 06:15:53 -0500 Received: from m43-15.mailgun.net ([69.72.43.15]:40393 "EHLO m43-15.mailgun.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725807AbgLULPw (ORCPT ); Mon, 21 Dec 2020 06:15:52 -0500 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1608549328; h=Content-Transfer-Encoding: Content-Type: In-Reply-To: MIME-Version: Date: Message-ID: References: Cc: To: From: Subject: Sender; bh=Y4CbVjRa9PKJTQWOMPwKVt5xzYyrbkTeQUsDXoEzPFU=; b=A9dIibCSRmXbMy3MFKt3q6kVEUwOV3RWsLj4RmRGrm+yDP1rUcVRLokMjKbm3Xt62W3MssJ/ 1YKpOZm4A3F4U2qXqzeViOeSvtN8gEmv/uQ4aaLa/B6/5tAVbz2riSbfXC5fuTT7H0zPVTU6 1S4Vh+nwSYJQ65eQrxO7pUk45GY= X-Mailgun-Sending-Ip: 69.72.43.15 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 5fe083ab7549779c5b126d5e (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Mon, 21 Dec 2020 11:14:51 GMT Sender: vjitta=codeaurora.org@mg.codeaurora.org Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 3680EC433ED; Mon, 21 Dec 2020 11:14:51 +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=-4.1 required=2.0 tests=ALL_TRUSTED,BAYES_00, NICE_REPLY_A,SPF_FAIL,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from [192.168.0.100] (unknown [182.18.191.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: vjitta) by smtp.codeaurora.org (Postfix) with ESMTPSA id D2058C433C6; Mon, 21 Dec 2020 11:14:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org D2058C433C6 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 Subject: Re: [PATCH v3] lib: stackdepot: Add support to configure STACK_HASH_SIZE From: Vijayanand Jitta To: Alexander Potapenko 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, kasan-dev References: <1607576401-25609-1-git-send-email-vjitta@codeaurora.org> <77e98f0b-c9c3-9380-9a57-ff1cd4022502@codeaurora.org> <6cc89f7b-bf40-2fd3-96ce-2a02d7535c91@codeaurora.org> <255400db-67d5-7f42-8dcb-9a440e006b9d@codeaurora.org> <7f2e171f-fa44-ef96-6cc6-14e615e3e457@codeaurora.org> <601d4b1a-8526-f7ad-d0f3-305894682109@codeaurora.org> <9e0d2c07-af1f-a1d3-fb0d-dbf2ae669f96@codeaurora.org> <48df48fe-dc36-83a4-1c11-e9d0cf230372@codeaurora.org> Message-ID: <6110a26b-dc87-b6f9-e679-aa60917403de@codeaurora.org> Date: Mon, 21 Dec 2020 16:44:36 +0530 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.5.1 MIME-Version: 1.0 In-Reply-To: <48df48fe-dc36-83a4-1c11-e9d0cf230372@codeaurora.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12/18/2020 2:10 PM, Vijayanand Jitta wrote: > > > On 12/17/2020 4:24 PM, Alexander Potapenko wrote: >>>> Can you provide an example of a use case in which the user wants to >>>> use the stack depot of a smaller size without disabling it completely, >>>> and that size cannot be configured statically? >>>> As far as I understand, for the page owner example you gave it's >>>> sufficient to provide a switch that can disable the stack depot if >>>> page_owner=off. >>>> >>> There are two use cases here, >>> >>> 1. We don't want to consume memory when page_owner=off ,boolean flag >>> would work here. >>> >>> 2. We would want to enable page_owner on low ram devices but we don't >>> want stack depot to consume 8 MB of memory, so for this case we would >>> need a configurable stack_hash_size so that we can still use page_owner >>> with lower memory consumption. >>> >>> So, a configurable stack_hash_size would work for both these use cases, >>> we can set it to '0' for first case and set the required size for the >>> second case. >> >> Will a combined solution with a boolean boot-time flag and a static >> CONFIG_STACKDEPOT_HASH_SIZE work for these cases? >> I suppose low-memory devices have a separate kernel config anyway? >> > > Yes, the combined solution will also work but i think having a single > run time config is simpler instead of having two things to configure. > To add to it we started of with a CONFIG first, after the comments from Minchan (https://lkml.org/lkml/2020/11/3/2121) we decided to switch to run time param. Quoting Minchan's comments below: " 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. " Thanks, Vijay >> My concern is that exposing yet another knob to users won't really >> solve their problems, because the hash size alone doesn't give enough >> control over stackdepot memory footprint (we also have stack_slabs, >> which may get way bigger than 8Mb). >> > > True, stack_slabs can consume more memory but they consume most only > when stack depot is used as they are allocated in stack_depot_save path. > when stack depot is not used they consume 8192 * sizeof(void) bytes at > max. So nothing much we can do here since static allocation is not much > and memory consumption depends up on stack depot usage, unlike > stack_hash_table where 8mb is preallocated. > -- QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation