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 C2C15C3064D for ; Thu, 27 Jun 2024 11:43:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DF5396B0099; Thu, 27 Jun 2024 07:43:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DA4E66B009B; Thu, 27 Jun 2024 07:43:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C444F6B00A9; Thu, 27 Jun 2024 07:43:15 -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 A126A6B0099 for ; Thu, 27 Jun 2024 07:43:15 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 1F7C1141C9A for ; Thu, 27 Jun 2024 11:43:15 +0000 (UTC) X-FDA: 82276482750.11.4ECF3B0 Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) by imf15.hostedemail.com (Postfix) with ESMTP id 87F63A001C for ; Thu, 27 Jun 2024 11:43:11 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=none; spf=pass (imf15.hostedemail.com: domain of xiujianfeng@huawei.com designates 45.249.212.191 as permitted sender) smtp.mailfrom=xiujianfeng@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1719488585; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5TQEXeprg7v1Zz0q1nNMjDOpm9wpf8ezsKzkICqTO5I=; b=injQ3eTL+LdeUAI9H1f3+rgiwYINnV7CsnNyg2eXqarixSwtPbvakhc2UgNXLqYIOF9XVn 5cGYn0age+GUMf24ZXJafsq+O/OTcOlJqy1jGXZw3wSZYZBWJ3EIezybhSmlc3ZPGWCl/R Fo8TeS+bC1nuiQGbCJCTRvYlb8psJok= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=none; spf=pass (imf15.hostedemail.com: domain of xiujianfeng@huawei.com designates 45.249.212.191 as permitted sender) smtp.mailfrom=xiujianfeng@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1719488585; a=rsa-sha256; cv=none; b=X1WzBjW/P00RnYSGVOVy7G9fGmOafUTjFBKpy2cKWBq+QphpZMAHIbwvAkB/FEtRbNgsAV 983S5zfMZRL/8ZJ1D+uR6lvqhPMgMOjhb8ThQkWKEmNQHmHm6fwQ2BP+S1a9Vtd4GNz8ME 5jQ9Nr2ohuAJr8NEkG6r5K+kBFRmRwc= Received: from mail.maildlp.com (unknown [172.19.88.214]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4W8xRY6Pqpz1j5qb; Thu, 27 Jun 2024 19:39:05 +0800 (CST) Received: from dggpeml500023.china.huawei.com (unknown [7.185.36.114]) by mail.maildlp.com (Postfix) with ESMTPS id A13301A016C; Thu, 27 Jun 2024 19:43:06 +0800 (CST) Received: from [10.67.110.112] (10.67.110.112) by dggpeml500023.china.huawei.com (7.185.36.114) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Thu, 27 Jun 2024 19:43:06 +0800 Message-ID: <10b948cd-5fbf-78e7-c3e8-6867661fa50b@huawei.com> Date: Thu, 27 Jun 2024 19:43:06 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.5.1 Subject: Re: [PATCH -next] mm: memcg: remove redundant seq_buf_has_overflowed() Content-Language: en-US To: Michal Hocko CC: , , , , , , , References: <20240626094232.2432891-1-xiujianfeng@huawei.com> From: xiujianfeng In-Reply-To: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.67.110.112] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpeml500023.china.huawei.com (7.185.36.114) X-Rspam-User: X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 87F63A001C X-Stat-Signature: 3yyxasd98ugzz5bx73dmws4j7dpcs144 X-HE-Tag: 1719488591-139145 X-HE-Meta: U2FsdGVkX19ejE1I/WRtGwMNx/KkHVe0gBPfO23NaKOF7W7S53/WaFvSySbZHZfjXOVsjtiFnvRMTDqMdt6iSDTogR4HK1ZfPHW4OM3PK0Rh+tpH/8sRiOXmhU+4whTl+YlbGTeKbG9wC8EpiJdA2kqG3e+lXnYei7O8JEhikTDouEohmfG7Y1ztdQvB8wI3Or20f5awXfAz+YEyZyVgowW+0xCKi4gbnIylITZs/vYrDd9NxMIdHMsKnnIbfXVMo1MnUcjDJSrEjLv0biqmLnYmlNd2i4NcG8btCTlpQ24QYslgp6JIRwjKGEi3ggTiKaQwWzfr2LY5otQGCN2mXVZepSQLko99qYrIIykihg4a+L/cwRtp+k8fZDRwSuldUpPhAUHODjAYeGApWBF64g317zRU94QbPpUClNiC/43EEgDAoLdlukSPprW6/k0qwh+PvP0auNqERS0z10nyIRdNI7xnOeAR7wn1mc7qC6Y4Iwtz2DGE1QDeGuy7/bLKoEU3S1silcaorsi3OvGELhi0jNDZD4tWg1KRzCzVMcCf4grHJPJbmaoCD1P3svWd2UhrGTraTlPve9UWxxIUHi9eQG9aSP3K3FlyuLVGnapxhiz3nJEo7M3pJmW0cIW8zd0GWkP+aHNfjn3oKCPYDDIXg3f7JKfOESFtMx+I0bR6JOy9ZbD2CHQYaymIiLILZ4ObToNRNDknAddD6pF8Y5+v69jYpwKAhrehXPcnkCoW3TCsYJuxmami9BRXfiRHO4zls6IliFLsupXlj6X+oB8CAli9qdHDx6WGJAYDRGX2HqyR42jgruuHBbaK4MpuXo+3Q0kYzzlbFITtbwSJvjrAaHuo1XpHwsiEAYke2r1MQdYuF9Jv1USD6KrxSYnIVP/Ze+L2b7oRXfrUJcmQXnEGPEHE6mM1gJ6tu2NirixIAiOF61OcnayhyTtGeAlhMYtqJjS5iMM0jAlVVd+ NnItCupm L0fmyccK6UXWlazY3e00cGXZ/rfBrwKE7FsN7ycUK2lr3Tcf+yhzM/3Q0jt0gcgqjjepAFBTD0HkwBqsFpjs0xYUcKk2G9PhdTtxrX5kew7LwLL9Tf7FmDlnrNOCohg4I0oPgjNhChFIeidkYy4ckvt70KziLALx+J1165GLmwS4kTCKtZh4iFXU3iQ== 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: List-Subscribe: List-Unsubscribe: On 2024/6/27 19:20, Michal Hocko wrote: > On Thu 27-06-24 16:33:00, xiujianfeng wrote: >> >> >> On 2024/6/27 15:13, Michal Hocko wrote: >>> On Wed 26-06-24 09:42:32, Xiu Jianfeng wrote: >>>> Both the end of memory_stat_format() and memcg_stat_format() will call >>>> WARN_ON_ONCE(seq_buf_has_overflowed()). However, memory_stat_format() >>>> is the only caller of memcg_stat_format(), when memcg is on the default >>>> hierarchy, seq_buf_has_overflowed() will be executed twice, so remove >>>> the reduntant one. >>> >>> Shouldn't we rather remove both? Are they giving us anything useful >>> actually? Would a simpl pr_warn be sufficient? Afterall all we care >>> about is to learn that we need to grow the buffer size because our stats >>> do not fit anymore. It is not really important whether that is an OOM or >>> cgroupfs interface path. >> >> I did a test, when I removed both of them and added a lot of prints in >> memcg_stat_format() to make the seq_buf overflow, and then cat >> memory.stat in user mode, no OOM occurred, and there were no warning >> logs in the kernel. > > The default buffer size is PAGE_SIZE. Hi Michal, I'm sorry, I didn't understand what you meant by this sentence. What I mean is that we can't remove both, otherwise, neither the kernel nor user space would be aware of a buffer overflow. From my test, there was no OOM or other exceptions when the overflow occurred; it just resulted in the displayed information being truncated. Therefore, we need to keep one. >