Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp2960282rwb; Mon, 5 Sep 2022 04:28:00 -0700 (PDT) X-Google-Smtp-Source: AA6agR7txpdUhGFt1ASEOreubxrF1DQO4F3dWt0o+FxYO6DCM1gsFvfmgr8z4z/LSDzBL+YYviV9 X-Received: by 2002:a05:6402:4007:b0:448:6c4c:b40 with SMTP id d7-20020a056402400700b004486c4c0b40mr31615825eda.422.1662377280324; Mon, 05 Sep 2022 04:28:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662377280; cv=none; d=google.com; s=arc-20160816; b=PbtEjjIq3ANgn0uBE7rDu1enbN2DZ6KsLXsdAnX5Cb6flDZJwOKwH/pkmfoEOt+Tk4 wH0XBj/0UqvURLUgTkH0gR1L3PaUsyXXh/DtA9nRlUjixl/JpemDwpwY8JNhjaaqG4S9 ikMjfNNj2Gr7pAdYNMM+MwFS8V0zHhBwzx7cqnyLMDUtgceOt5Fj9Ch1rKOe3KZRy/Bx UHTzQdLP5pSYAE3qUWPoB1fDPASqiZRBsRLFEPSyN17YWHtqkKHUSR+MMO4aBVgzLQWW BQP4lowgmP/EqXWCc7IYjlZ9X6Klj72wLf0BQBmB6WFvJmMmlVaq3llsm9sDhMYwMnOm tHMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=o7Bepl61brMl8iyRpyHf3BdMouTwahtaWaNTgppx2/g=; b=ZrvYjj2WkMuDTxwuiK+mtMNiVIgSd8db6MhTWah6eLdgxKbOToaUoqz8c+gEPi0Iz1 4UQX4EjV9WEB4szSmaA33+QLQR02bAZmItk1Wahhjmb5jUA+snS4NQTvH1gdSE3xqpCz x4bCjIcYCU1Co44JNN62ZFGaCtE8dx2D+kMAxJQiT7/lhLs/MUcOyQ/QmOt+gG5n4p1c Cn/fXcL84k0+tWAT6Sc2QlbsQZ8f7yzHwXRTjkvtotJ5ABemq7iMgU6FU6kSA4nHsls0 N7FIjP6KcQ4HWa5v5U5tja1XvaD3l4/ZBRVwQ8uo9ePx9k7oAnzyKP21TAkArGOF5XbD KJsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gnuweeb.org header.s=default header.b=nCir+0wH; 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 f17-20020a0564021e9100b004482384c271si8670412edf.621.2022.09.05.04.27.33; Mon, 05 Sep 2022 04:28:00 -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=nCir+0wH; 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 S237717AbiIEKv7 (ORCPT + 99 others); Mon, 5 Sep 2022 06:51:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34130 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230073AbiIEKvy (ORCPT ); Mon, 5 Sep 2022 06:51:54 -0400 Received: from gnuweeb.org (gnuweeb.org [51.81.211.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 57AC14E625 for ; Mon, 5 Sep 2022 03:51:52 -0700 (PDT) Received: from localhost.localdomain (unknown [182.2.42.181]) by gnuweeb.org (Postfix) with ESMTPSA id 4D71C804D1; Mon, 5 Sep 2022 10:51:47 +0000 (UTC) X-GW-Data: lPqxHiMPbJw1wb7CM9QUryAGzr0yq5atzVDdxTR0iA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1662375111; bh=c9zeHPFx76P0oLkPbZmlW5hML9U+k3vaPD6cjMJ/lpY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nCir+0wH/YIfJUt8VqCmGvtKYo5+Mny+OxFeEHP3YszeSd5OgbwXTfyJ7HwbI5ouc RsX0MXSkY1w0ZdwQXdPwc0HMKg4+J4UWYeRcZjR7qk5x87WQUNmdGjM/lqLCfsJ9Rd AO0RUOGOfNmM8felbyyR+n7g7n4nTfK/Fyx98GpBK5GcD6Xma1Ak2r7VDtrzpu1s/j VI6mI+p7U+wAVsXJtIVWIiaEldFWqaoBlHM/P2ZHeKiyXjQZzXS/FEXJjlCS7QwALV WHUqHMcZS5vK/fAy0kpph/95q45xWJwXKxlKzMuUOi7ELUP2a2dICM5wwnkZb4e3+i scDzCTRRT6uhg== From: Ammar Faizi To: Oscar Salvador Cc: Andrew Morton , Linux Kernel Mailing List , Linux Memory Management Mailing List , Michal Hocko , Vlastimil Babka , Eric Dumazet , Waiman Long , Suren Baghdasaryan , Marco Elver , Andrey Konovalov , Alexander Potapenko Subject: Re: [PATCH v2 3/3] mm,page_owner: Filter out stacks by a threshold counter Date: Mon, 5 Sep 2022 17:51:37 +0700 Message-Id: <573c4049045a5ff342ff9998c69dfae7-ammarfaizi2@gnuweeb.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220905031012.4450-4-osalvador@suse.de> References: <20220905031012.4450-1-osalvador@suse.de>, <20220905031012.4450-4-osalvador@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_SORBS_WEB,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no 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 Mon, 5 Sep 2022 05:10:12 +0200, Oscar Salvador wrote: > +static int page_owner_threshold_show(struct seq_file *p, void *v) > +{ > + seq_printf(p, "%lu\n", threshold); Remove a slipped leading 0x20 space here (before seq_printf()). > + return 0; > +} > + > +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); > + if (!kbuf) > + return -ENOMEM; > + > + if (copy_from_user(kbuf, buf, count)) { > + ret = -EFAULT; > + goto out; > + } > + > + kbuf[count - 1] = '\0'; > + > + ret = kstrtoul(kbuf, 10, &threshold); > + > +out: > + kfree(kbuf); > + return ret ? ret : count; > +} Still the same comment on this, kmalloc() is not really needed here. Capping the size to PAGE_SIZE (usually 4K) is too big. `unsinged long` is 64-bit at most, this means the max val is 18446744073709551615 (20 chars). The lifetime of @kbuf is very short as well, using a stack allocated array of chars is fine? Untested: static ssize_t write_page_owner_threshold(struct file *file, const char __user *buf, size_t count, loff_t *pos) { char kbuf[21]; int ret; count = min_t(size_t, count, sizeof(kbuf)); if (copy_from_user(kbuf, buf, count)) return -EFAULT; kbuf[count - 1] = '\0'; ret = kstrtoul(kbuf, 10, &threshold); return ret ? ret : count; } -- Ammar Faizi