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 63856C77B75 for ; Tue, 18 Apr 2023 14:10:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A40CA8E0001; Tue, 18 Apr 2023 10:10:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9F09E6B0072; Tue, 18 Apr 2023 10:10:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8E01C8E0001; Tue, 18 Apr 2023 10:10:57 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 814656B0071 for ; Tue, 18 Apr 2023 10:10:57 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 52E441202F5 for ; Tue, 18 Apr 2023 14:10:57 +0000 (UTC) X-FDA: 80694698154.22.76FB9E1 Received: from out203-205-251-60.mail.qq.com (out203-205-251-60.mail.qq.com [203.205.251.60]) by imf09.hostedemail.com (Postfix) with ESMTP id 73F49140021 for ; Tue, 18 Apr 2023 14:10:53 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=foxmail.com header.s=s201512 header.b=duQAsWHd; spf=pass (imf09.hostedemail.com: domain of wenyang.linux@foxmail.com designates 203.205.251.60 as permitted sender) smtp.mailfrom=wenyang.linux@foxmail.com; dmarc=pass (policy=none) header.from=foxmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1681827054; 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:dkim-signature; bh=+208pgXfl4w8GOcDOeVQ9M2aIjRfEpbYKOHFbFJRhO4=; b=3T9p/WPJiLDZ0h16y5q5+p+O+WXfeQSqZJBU+R5XS7V5LHBcw+QwG1FxmXL5g0GoPitZQh KWptAzUnXKYO1GMhSPY90MH4xn39jV4nOLOBxHbL9++7CSO64miwZdiiHHVdsUW2gWh4/c n6VVoIIA0+IC2kM9p3J9OTDY/dpq0V8= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=foxmail.com header.s=s201512 header.b=duQAsWHd; spf=pass (imf09.hostedemail.com: domain of wenyang.linux@foxmail.com designates 203.205.251.60 as permitted sender) smtp.mailfrom=wenyang.linux@foxmail.com; dmarc=pass (policy=none) header.from=foxmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1681827054; a=rsa-sha256; cv=none; b=r7FJT8W7G87rq1WXl92f0U3SkmnVgJD5uSZ+vInw/z7T4IunBrUKiAKSDb4BAPR9k4e4IL YGaGIWYvNCrjrIPC3uzNqhhFjxzVRblR+1PttUJv7mRDIiF3u8aEuCLFUFBoQfasvhushR lFgrw5Cou+eobtoy3MpXhV7OT630AMk= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1681827034; bh=+208pgXfl4w8GOcDOeVQ9M2aIjRfEpbYKOHFbFJRhO4=; h=Date:Subject:To:Cc:References:From:In-Reply-To; b=duQAsWHdP5qlOnnWGlSu2wWKWc5S48qYrLpiDYG4XOKPhHf0o54UexMg7TFmk5uF0 0RfYh7N33U88DE1HFHiR6Q7PTIz5wartV/DCkD+NeTv/p4LsctTEuoXWaFvwHpxwnM as71XdLc2AynmSEARmQ4GoIZyMAE2N9+hhiMDNkE= Received: from [192.168.31.3] ([106.92.97.36]) by newxmesmtplogicsvrsza10-0.qq.com (NewEsmtp) with SMTP id 2A090E66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YOxtcyZbdC75/t53tfVdQiYaNUv28sfT+E/s+ZmkSdtLh8Y= X-OQ-MSGID: <3a718c6a-328d-5da2-5843-7d552d34c111@foxmail.com> Date: Tue, 18 Apr 2023 22:10:32 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.9.1 Subject: Re: [PATCH] mm: compaction: optimize compact_memory to comply with the admin-guide To: Mel Gorman Cc: Andrew Morton , Oscar Salvador , William Lam , Fu Wei , linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20230411134801.a4aadef5aba0f51e0d44bb7a@linux-foundation.org> <20230417111352.v26slrcmz4qo3tnn@techsingularity.net> From: Wen Yang In-Reply-To: <20230417111352.v26slrcmz4qo3tnn@techsingularity.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Stat-Signature: nrnehpomcsnxbnjhpm8xgaqfzk1c5k1s X-Rspam-User: X-Rspamd-Queue-Id: 73F49140021 X-Rspamd-Server: rspam06 X-HE-Tag: 1681827053-103674 X-HE-Meta: U2FsdGVkX19unMq48sDbNL42U5TwRBISGnnWq+1I9ICLrlU3ZYwuifcoeojgLb6x5l8fAbIOEDpqYWn+40F8AZ8hvhcOfn4dZ4TFlySo25eBSU5+jPyxkzx0v7DinUvBBPnAzsxl5nnMpj2V2Dxugdpu2qNTX5c67b9pnV0H8Rv0j1hQoPmsNP1p/irtlJpgXHhNu+1lTFw3zA5JbbOaafAsMVWZnSDPSC8lZRB4s0hEYWHN3C9FjWFmJcNIaKTUjt1+Y+iQ/sLZQ//jYczQfrtTp0ik99MPZzZleYaGMtBF/LN9jDrqZaablynThWxfaRqL1E0aRb2o+WvKq/YE3eXheFm9cPRmF6/0NJ1tIqrXSqJsifC4ZYrpS0MKDuU4o4LVo0jjw/lQcrSAIkoW3w9zvK0O1iUpxn9Buao5jiVEdJxRzAvW9+8gKC8H1xvOIRbSLt2L2FpusRPi4PJHwO45/ylB4AXusXQI8hJOWg6DBbuXoZwZ7P8QiRmU0Jv7DKsOk84pgY7CvZDCd86MSvn72EDN/B71JOCUeX7wvpKW5YTAD/PbFUzKhSTf8X4UKaDaGhhJ3BejvJ8KpTw7HUXKsc4sO3bKxAefrGx3ZN93sCmdlintZG5QSzZTi9FIlADCHwGXyfBITzFoHkmNj+O3CttPkTEu0LsAYSBIc4chKBk0fcQa8gg4wqUdYmxFqCmWo4VERdDFSqZpdyEJhAoedity++fB05xd+Od+l7oB5bV/P/KriG5dw40A8u9M27os8k11PXI0wQGhgU9ReE/rhvmLqU/3k0NcY95Y8Y9N1DB3tpyHCDLNy3sIWTBg8N8GEfm3aW2mWI1UWUhAQOMxP/MzQHpi7HZrMB+BDDQtfw8L/bMq9EQyBIUwZl2/UZYA/EIZX80snUFCUqCVMmg6tl7OHWcO7hSBRNe965ml4Aqz+AinfkZwNT2TMWfE9MUGGQ+c2p2GCVQsU6B m7GKWERI L0UL1c+P2BKIYSB8GYCL7MVspIkwcFRxciOfACoL3GKG45Dli+oQ3W32MwKIRY1KlhXQAtiwxDPeLp7SNPeqLYoPstcnFP5Wm4ccLVrs1sxg/s9HZgr26icarY77TH4Q05mWpW+RyroG4XXF7il8epX/PlOpSgI+WEABC45189Eccv6HEkHB9zH475AL6d93exeGzkywoGoybBf+FmjN/TPlQSyObKr4EajvVUjD31M6VRFa6wEMAtb1/K/ZPNe0kPBNA1ytCsoFDt9KSo+aHJuhYIlrIlAfJdujcQl06ODsoQLv/+6U7Yoa/jS+fWGu7ybs6frQvCW3iT9AqJM5ZIuP8QHZ4iP85IiSqjpuPD3k8B+mAhHI7dQFI1ywdXxgkcDj5eeYFz9Lqy73ug2nRbniUrQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.001403, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 在 2023/4/17 19:13, Mel Gorman 写道: > On Sun, Apr 16, 2023 at 01:42:44AM +0800, Wen Yang wrote: >> ??? 2023/4/13 00:54, Wen Yang ??????: >>> ??? 2023/4/12 04:48, Andrew Morton ??????: >>>> On Wed, 12 Apr 2023 02:24:26 +0800 wenyang.linux@foxmail.com wrote: >>>> >>>>> For the /proc/sys/vm/compact_memory file, the admin-guide states: >>>>> When 1 is written to the file, all zones are compacted such that free >>>>> memory is available in contiguous blocks where possible. This can be >>>>> important for example in the allocation of huge pages although >>>>> processes >>>>> will also directly compact memory as required >>>>> >>>>> But it was not strictly followed, writing any value would cause all >>>>> zones to be compacted. In some critical scenarios, some applications >>>>> operating it, such as echo 0, have caused serious problems. >>>> Really?  You mean someone actually did this and didn't observe the >>>> effect during their testing? >>> Thanks for your reply. >>> >>> Since /proc/sys/vm/compact_memory has been well documented for over a >>> decade: >>> >>> https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/tree/Documentation/admin-guide/sysctl/vm.rst#n109 >>> >>> >>> it is believed that only writing 1 will trigger trigger all zones to be >>> compacted. >>> >>> Especially for those who write applications, they may only focus on >>> documentation and generally do not read kernel code.  Moreover, such >>> problems are not easily detected through testing on low pressure >>> machines. >>> >>> Writing any meaningful or meaningless values will trigger it and affect >>> the entire server: >>> >>> # echo 1 > /proc/sys/vm/compact_memory >>> # echo 0 > /proc/sys/vm/compact_memory >>> # echo dead > /proc/sys/vm/compact_memory >>> # echo "hello world" > /proc/sys/vm/compact_memory >>> >>> The implementation of this high-risk operation may require following the >>> admin-guides. >>> >>> -- >>> >>> Best wishes, >>> >>> Wen >>> >>> >> Hello, do you think it's better to optimize the sysctl_compaction_handler >> code or update the admin-guide document? >> > Enforce the 1 on the unlikely chance that the sysctl handler is ever > extended to do something different and expects a bitmask. The original > intent intent of the sysctl was debugging -- demonstrating a contiguous > allocation failure when aggressive compaction should have succeeded. Later > some machines dedicated to batch jobs used the compaction sysctl to compact > memory before a new job started to reduce startup latencies. > > Drop the justification "In some critical scenarios, some applications > operating it, such as echo 0, have caused serious problems." from the > changelog. I cannot imagine a sane "critical scenario" where an application > running as root is writing expected garbage to proc or sysfs files and > then surprised when something unexpected happens. > Thanks for your comments. We will modify it according to your suggestion and then send v2. -- Best wishes, Wen