Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp432008rwe; Thu, 1 Sep 2022 01:50:56 -0700 (PDT) X-Google-Smtp-Source: AA6agR5hbPhfddKAmUVJDo5mOLJAPoyX51SjKe7d5ASJWJbiYVkhdu6TbE++MydndySsEkhQPvEs X-Received: by 2002:a05:6402:35d4:b0:446:88da:9bd5 with SMTP id z20-20020a05640235d400b0044688da9bd5mr28628643edc.415.1662022256181; Thu, 01 Sep 2022 01:50:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662022256; cv=none; d=google.com; s=arc-20160816; b=gX6ppZgRi5i7MItGihuceAUxPwsqSfBRsIPK883oLWVoDRBCHbt5NaV+TDLwJHfqKm sUAcplULXiidhKgva/Y+xD4hDl1QsnXP3wITR5WQIkGTpjpqmb30xiPFw8FRm7HtKqWg eKUeE037tArtGEIO6LTcHoHSa9EPiQbAeq7QxmHm9b43JjgcZhuEbSD68LzMJJGJxzOp WPa9Q3oIlu4DRy41uzqkVquD+te+FYShYTjf36OB1OSt4rs/ncAoaH/0WoKtfVHmyfvn O6QBisiW1LR4jNe8qcMq3VgXImf2xUNpLSeN7MDy1uEqt3+BaLU2pkd/vY7OtI+ICiwL GuMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:subject :from:references:cc:to:content-language:user-agent:mime-version:date :message-id:dkim-signature; bh=sR1xd8MLiaZb0kklWi+YPDnFAGQwqF5+hHy7KJ3N58M=; b=FGkjJ7sJkueJLfETx/kML6/IT2x/44Ix1r6SawtnlxprhCHdaZoJrU0KbjVbnPGDn4 HnGmtX3yF4gF3dpLtL6VyRVxuwppTx79VZyIq30vipr975mK82T4aQi6LZOJKtPMGCiG cdTD4xRNMf7wuEzvirwdd1in2MgwwrW0RiBP28Pya4v2R5msUmWBluqsVaVY1s4e/Op6 74awXu6/9LywWx0Csr2O0JveQRX8WhhYcQewDXNFmrcUVu8kTYXgTGDw8lFxIwQnHOQ+ 4pph8O24cb72Dqx5QBbQx4MR4r2nktjfSEg0Ea8NDc2rhc6427AzGq8NgMQm67XD2LNB Oikw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gnuweeb.org header.s=default header.b=JNpAuVJ5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnuweeb.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r12-20020a05640251cc00b00447dc8a0cdfsi1572052edd.506.2022.09.01.01.50.21; Thu, 01 Sep 2022 01:50:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gnuweeb.org header.s=default header.b=JNpAuVJ5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnuweeb.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233839AbiIAIRB (ORCPT + 99 others); Thu, 1 Sep 2022 04:17:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55100 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233632AbiIAIQ7 (ORCPT ); Thu, 1 Sep 2022 04:16:59 -0400 Received: from gnuweeb.org (gnuweeb.org [51.81.211.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2CF7CC9E8D for ; Thu, 1 Sep 2022 01:16:54 -0700 (PDT) Received: from [192.168.210.80] (unknown [182.2.39.249]) by gnuweeb.org (Postfix) with ESMTPSA id E4CB880866; Thu, 1 Sep 2022 08:16:48 +0000 (UTC) X-GW-Data: lPqxHiMPbJw1wb7CM9QUryAGzr0yq5atzVDdxTR0iA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1662020213; bh=lq7B7oslVdIFiKkrtZ+qbc4fMNOk/JK8jrKwVYgHXPA=; h=Date:To:Cc:References:From:Subject:In-Reply-To:From; b=JNpAuVJ5a6I0m+tL/+XHuHKTzItsLB+ceDJbHSItVsXP9EsqQmDwuJYhOvdaVswvB w0CT9IqSEsd8UB92uuaWDVJmV9vAV2CzDGSSgrdftCyysK0yqBrVhLtkK+u+WruiXS q1jzDD20kX1K7oxyYPIouYw9X/J1o6Y2PHtWlhOaWZnOgYB7hGLH3vXiW/HepViXx3 W4cCpoXMWUoWCTsEODYNb9fraO6elr7AIJON+RGJK3NZYNbnEvFRGuIJxzMIz/WUt7 Gh2Dpo4l0xmv8b7KkP8gwwAmdsb5b56iWv13mBPxfe+iq8nbbctsM9OHoSYSx8dmsz GEhU22TS/WgRw== Message-ID: <9f2ef1ac-c0a1-eb77-8e68-e9a60bc8efd2@gnuweeb.org> Date: Thu, 1 Sep 2022 15:16:44 +0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Content-Language: en-US To: Oscar Salvador Cc: Linux Kernel Mailing List , Linux MM Mailing List , Andrew Morton , Michal Hocko , Vlastimil Babka , Eric Dumazet , Waiman Long , Suren Baghdasaryan , Ammar Faizi References: <20220901044249.4624-1-osalvador@suse.de> <20220901044249.4624-3-osalvador@suse.de> From: Ammar Faizi Subject: Re: [PATCH 2/3] mm, page_owner: Add page_owner_stacks file to print out only stacks and their counter In-Reply-To: <20220901044249.4624-3-osalvador@suse.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 9/1/22 11:42 AM, Oscar Salvador wrote: > +static unsigned long last_stack = 0; This @last_stack can just be a static local variable in the new function you wrote, read_page_owner_stacks(), since no other functions use it. > +static ssize_t read_page_owner_stacks(struct file *file, char __user *buf, > + size_t count, loff_t *pos) > +{ > + char *kbuf; > + int ret = 0; > + > + count = min_t(size_t, count, PAGE_SIZE); > + kbuf = kmalloc(count, GFP_KERNEL); > + if (!kbuf) > + return ENOMEM; Missing a negative sign, return -ENOMEM; > + ret += stack_depot_print_stacks_threshold(kbuf, count, pos, &last_stack); > + if (copy_to_user(buf, kbuf, ret)) > + ret = -EFAULT; > + > + if (!ret) > + last_stack = 0; > + > + kfree(kbuf); > + return ret; > +} -- Ammar Faizi