Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp1499432rwe; Thu, 1 Sep 2022 21:17:15 -0700 (PDT) X-Google-Smtp-Source: AA6agR4IYrp4AZNGY4Z2Jd95mUfBvl+VCyDXdfBs+t77IvMylM+VPVzAHToWMjS7q6kwcsCL+do1 X-Received: by 2002:a17:903:41c6:b0:16e:fb38:e2c7 with SMTP id u6-20020a17090341c600b0016efb38e2c7mr34093964ple.75.1662092234873; Thu, 01 Sep 2022 21:17:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662092234; cv=none; d=google.com; s=arc-20160816; b=Xeltd1AtUYS+Yy5FWw4MpeQeG5ffuHl+LK2DUSQYEcXXDzjby/aaWVvxgm//VeNpcb ezmA8jKT5lUVOaKDOkG3AtJtdpMdzAf0YaKIthDMwJgFSggk+2rPoMSonVo9PGrlOS2d kCp7TvJJ2kwy+9Z2GY+hTaTgFHYuVaSDX2WWG0cBaI915Wk7yBDl0N78T0txFF2s3k2t 4kKcU0IdihUzxyK+RVLZb8QV9eCpS1fi1FL7EuflKGVqFmSnLAO9GlcCgPiqnUONBwJ0 TSYx3qFf0crhCQPdDjz0hqv9DGarx1wjCETSgyg64o/jaIEpP4LkO6KqtaiwzC96wmi5 btnA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature :dkim-signature; bh=ZkNCttB8nL0NEMNWZvlIH1QlSGEhIWYoquG6rqGhkS4=; b=VPr4JFHB5ybhZ/ifak3l61vrsiBJao/QFaP127hmYtxT1qR5hqlm2FejqLI0cNQpC+ FpSyArszjc8CbWUWHmNzSPSbedhfz2iepTdvOng5fUbIOXS1AlV3NYQ69sYtkiKb6X6i 8tZIVXkwRwmnGmzFNYQqwc9j9OT3iUH+3EHEiyL10vIAVrlE45b4pq8Jz66TG+XuzD+g EmGELG7fDynNX0LblotVnD67WsnPUJNmT4TVMcnHT/CfEUXY7fwFWw9UBNtF+NhUHVz8 D89iixG9Jcodjb1A1PS24MpTeOSLFS+KfHinIdmsYZm66yAw/PnOavk30BTd5mVONmAJ 28PQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b="u/quP4AR"; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=c3yZR+H3; 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=suse.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 1-20020a17090a000100b001f0fb79b75csi959663pja.81.2022.09.01.21.17.04; Thu, 01 Sep 2022 21:17:14 -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=@suse.de header.s=susede2_rsa header.b="u/quP4AR"; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=c3yZR+H3; 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=suse.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234406AbiIBDgi (ORCPT + 99 others); Thu, 1 Sep 2022 23:36:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51894 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232186AbiIBDgf (ORCPT ); Thu, 1 Sep 2022 23:36:35 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1910C2A27D for ; Thu, 1 Sep 2022 20:36:34 -0700 (PDT) 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> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,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 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