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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id B5CD2ECAAA1 for ; Fri, 2 Sep 2022 03:36:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 182AA800AC; Thu, 1 Sep 2022 23:36:35 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 131A18008D; Thu, 1 Sep 2022 23:36:35 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 020AB800AC; Thu, 1 Sep 2022 23:36:34 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id E58328008D for ; Thu, 1 Sep 2022 23:36:34 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id BA1E81C29C4 for ; Fri, 2 Sep 2022 03:36:34 +0000 (UTC) X-FDA: 79865733108.30.0994244 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by imf29.hostedemail.com (Postfix) with ESMTP id 4EBB112007E for ; Fri, 2 Sep 2022 03:36:34 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 44B2C33D6F; Fri, 2 Sep 2022 03:36:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1662089793; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=ZkNCttB8nL0NEMNWZvlIH1QlSGEhIWYoquG6rqGhkS4=; b=u/quP4ARFHBcFudmWirOqpVneENd8QUD8egAiOsF70vkDJfMPUDtfPXDqi12XtZyKYWaOv xGe552Dw1y/PR9kH2GYQMMl2m2I8tMT0XTsCXNLdojcZjDEXwnsoDj6j3awV9YGL8vAy58 ag3MaAWpET0+zw+wvnLjQITscmz1Wm4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1662089793; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=ZkNCttB8nL0NEMNWZvlIH1QlSGEhIWYoquG6rqGhkS4=; b=c3yZR+H3YCJUB/52NbGOiumODHmObGSLt8iFdJiiRODpm5UaNl8jH2KS4lY24MFy7KHgOx JVxoOkUzLMpyyWAQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id B5FCC133DD; Fri, 2 Sep 2022 03:36:32 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id oFutKUB6EWOdDwAAMHmgww (envelope-from ); Fri, 02 Sep 2022 03:36:32 +0000 Date: Fri, 2 Sep 2022 05:36:31 +0200 From: Oscar Salvador To: Ammar Faizi Cc: Andrew Morton , Linux Kernel Mailing List , Linux MM Mailing List , Michal Hocko , Vlastimil Babka , Eric Dumazet , Waiman Long , Suren Baghdasaryan Subject: Re: [PATCH 3/3] mm,page_owner: Filter out stacks by a threshold counter Message-ID: References: <20220901044249.4624-1-osalvador@suse.de> <20220901044249.4624-4-osalvador@suse.de> <3c69f09e-1e34-73f9-b38b-733971ef38cb@gnuweeb.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3c69f09e-1e34-73f9-b38b-733971ef38cb@gnuweeb.org> ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1662089794; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=ZkNCttB8nL0NEMNWZvlIH1QlSGEhIWYoquG6rqGhkS4=; b=DLchFoSYrtMDBhjb9vPrBU35lbfbddjYpUl9evE8eqRNhNzFaNT3qFN9QPwnhqwh00HLU/ zOyRlPRNjcNZVx7+0Dk2iad2YI0Tx5k5VtQRsEH4jkf0K9q5cd75iwY3stVJMt4VhpfRcZ JhYeAz6kY00RFLHroeby63E5LCYAeQw= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=suse.de header.s=susede2_rsa header.b="u/quP4AR"; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=c3yZR+H3; dmarc=pass (policy=none) header.from=suse.de; spf=pass (imf29.hostedemail.com: domain of osalvador@suse.de designates 195.135.220.28 as permitted sender) smtp.mailfrom=osalvador@suse.de ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662089794; a=rsa-sha256; cv=none; b=QGItInM02ENNDzZsA42yRPgdCBQqxIz9vISg668kOLJd572QnmuHoflKi1sYUl+NeANooW UP3ja7vdq/2PiHgWmv8YGZHOt6j/pbywTqjIGWi2+03pu6Fppw6s2FGyNkiJtdyDkN0Dx+ HAmM4t0KKwmexoU5ncoE/k61cg3PMds= Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=suse.de header.s=susede2_rsa header.b="u/quP4AR"; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=c3yZR+H3; dmarc=pass (policy=none) header.from=suse.de; spf=pass (imf29.hostedemail.com: domain of osalvador@suse.de designates 195.135.220.28 as permitted sender) smtp.mailfrom=osalvador@suse.de X-Rspamd-Queue-Id: 4EBB112007E X-Stat-Signature: za65c7aqfj59jrr78jmnmd4t7wucbeuc X-Rspam-User: X-Rspamd-Server: rspam02 X-HE-Tag: 1662089794-552165 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, Sep 01, 2022 at 03:31:51PM +0700, Ammar Faizi wrote: > On 9/1/22 11:42 AM, Oscar Salvador wrote:> +static ssize_t read_page_owner_threshold(struct file *file, char __user *buf, > > + kbuf = kmalloc(count, GFP_KERNEL); > > + if (!kbuf) > > + return ENOMEM; > > Missing a negative sign, return -ENOMEM. Will fix. > > +static ssize_t write_page_owner_threshold(struct file *file, const 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); > > This looks overestimating to me. For unsigned long, on a 64-bit system > has max val 18446744073709551615 (20 chars). > > You can use stack a allocated local variable with length 21. No need > to use kmalloc(). The same way with the read() op. Probably could do that, but I'll go with Michal's option and will use seq_file. Thanks! -- Oscar Salvador SUSE Labs