Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp2718914rdd; Fri, 12 Jan 2024 21:57:53 -0800 (PST) X-Google-Smtp-Source: AGHT+IGDHa2K4Zv+wjr4lXjrdogXh9Bnas3PP/AP/qyTRieg3gQXYx6Ws4GTB382YgB6C0IFQTfU X-Received: by 2002:a19:6403:0:b0:50e:c6f4:9674 with SMTP id y3-20020a196403000000b0050ec6f49674mr1178106lfb.116.1705125473632; Fri, 12 Jan 2024 21:57:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705125473; cv=none; d=google.com; s=arc-20160816; b=xVBPHvdDv0Tmtwo0/W6fy6Q457W5Zt8O7JPQENIbjTJwtnQUZXdtJH+gU/hdPVOfnc cpIVrQWFwydC7/HnEF73T8dGDojSKq9GzktXrFfeuzCybjbqZBUgqIxb/YzVygpvHHQh cR+Wux5tex1kg3FGfcscN2foqz7x3ko1E65OcGrBD/lTSU1maina8BRds03C0RTTAa9F zj3kAPQ1IXLFd7oTRzlMH72nH3ht83bPloSQgrhAFL4T+lILGrNwSWQEkO9Ymr12PNwA K9JoPLnfYc5qe+Caqs4kpBLnXIaKW0qlod9tDA0C6Jmd1v6l+i4qNkJg/XVnzrc7mjXU w8Ag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=LZO2x9yldtzud/x4dS/NjSRPLqqIWVFdBp7jzJpTEJg=; fh=F9cRDawVmsaRii2qzrrB3phb3BChye/jXWzrobYbuHE=; b=qr/G98ufNWyjMtFpGPc8aFn7pV4OtAk/IOVd1cwCUGwRJz6SgMWd04N4mq22fYNLi0 HKPoUARt9tSDJZkk99QWFaF5QYJD/3zOj5mQ448rbr+ZFDeBpGsHpw7icU0XK9U/oX8K gP1FXbVOAyoJhdo3ixwb11wia1Tm9BwhLsY5fta4g5nd2pSMBQ+zC0RtHjRvvh1TYdKq uK6O3K5EjbygFqEpTsapQb8SxVg6PSJvx3+DGD0LHfXXwBAjVRtDNFxAYIl4UhGFgzq7 HQqPARIg8avv7Dq/TUl7ziPqDjGHLnAzVz+cpa7wI2+dAKCJbELBrsfaOtIX4IfSahtR 7AJA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-25200-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-25200-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=antgroup.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id w25-20020a1709064a1900b00a27aa152f29si2040152eju.416.2024.01.12.21.57.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Jan 2024 21:57:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-25200-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-25200-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-25200-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=antgroup.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 5DCBF1F23B25 for ; Sat, 13 Jan 2024 05:57:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7D77218EAF; Sat, 13 Jan 2024 05:57:49 +0000 (UTC) Received: from out0-221.mail.aliyun.com (out0-221.mail.aliyun.com [140.205.0.221]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2B2AD18C21 for ; Sat, 13 Jan 2024 05:57:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=antgroup.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=antgroup.com X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R121e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018047205;MF=libang.li@antgroup.com;NM=1;PH=DS;RN=5;SR=0;TI=SMTPD_---.W59eyl6_1705125139; Received: from 30.39.211.193(mailfrom:libang.li@antgroup.com fp:SMTPD_---.W59eyl6_1705125139) by smtp.aliyun-inc.com; Sat, 13 Jan 2024 13:52:20 +0800 Message-ID: Date: Sat, 13 Jan 2024 13:52:17 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] mm/compaction: Reduce unnecessary loops Content-Language: en-US To: Andrew Morton Cc: , , "=?UTF-8?B?5pyx6L6JKOiMtuawtCk=?=" , "=?UTF-8?B?WWFuIFlhbihjYWlsaW5nKQ==?=" References: <20240112073524.80724-1-libang.li@antgroup.com> <20240112112551.bbc9d5114fd2c6fb421fed2d@linux-foundation.org> From: "Bang Li" In-Reply-To: <20240112112551.bbc9d5114fd2c6fb421fed2d@linux-foundation.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 2024/1/13 3:25, Andrew Morton wrote: > On Fri, 12 Jan 2024 15:35:24 +0800 "Bang Li" wrote: > >> Compaction will be triggered when we write 1 to '/proc/sys/vm/ >> compact_memory'. During the execution of the process, when we send >> SIGKILL to terminate the compaction, the process does not exit >> immediately. Instead, it will continue to loop through the remaining >> zones and nodes before exiting. >> >> in my environment: >> >> [root]# cat /proc/buddyinfo >> Node 0, zone DMA 1 1 1 0 2 1 1 0 1 1 3 >> Node 0, zone DMA32 1666 1123 804 625 488 356 321 278 209 178 250 >> Node 0, zone Normal 58852 83160 49983 9812 2287 1229 19604 24471 10346 5219 12205 >> [root]# echo 1 > /sys/kernel/debug/tracing/events/compaction/mm_compaction_end/enable >> >> before the patch: >> >> [root]# timeout --signal=SIGKILL 0.002 bash -c 'echo 1 > /proc/sys/vm/compact_memory' >> [root]# cat /sys/kernel/debug/tracing/trace_pipe >> <...>-26494 [014] ..... 226.468993: mm_compaction_end: zone_start=0x1 migrate_pfn=0xe00 free_pfn=0xe00 zone_end=0x1000, mode=sync status=complete >> <...>-26494 [014] ..... 226.469718: mm_compaction_end: zone_start=0x1000 migrate_pfn=0x20a80 free_pfn=0xffe00 zone_end=0x100000, mode=sync status=contended >> <...>-26494 [014] ..... 226.469720: mm_compaction_end: zone_start=0x100000 migrate_pfn=0x100000 free_pfn=0x307fe00 zone_end=0x3080000, mode=sync status=contended >> >> after the patch: >> >> [root]# timeout --signal=SIGKILL 0.002 bash -c 'echo 1 > /proc/sys/vm/compact_memory' >> [root]# cat /sys/kernel/debug/tracing/trace_pipe >> <...>-17491 [053] ..... 109.005387: mm_compaction_end: zone_start=0x1 migrate_pfn=0xe00 free_pfn=0xe00 zone_end=0x1000, mode=sync status=complete >> <...>-17491 [053] ..... 109.006139: mm_compaction_end: zone_start=0x1000 migrate_pfn=0x22220 free_pfn=0xffe00 zone_end=0x100000, mode=sync status=contended >> >> Although it exits quickly after receiving the SIGKILL signal, a better >> solution is to terminate the loop early after receiving the SIGKILL >> signal. >> > > What is the use case here? The requirement? Why is this change > valuable to anyone? Thanks for the quick reply! I'm very sorry that my inappropriate use case confused you. What I want to explain is that when receiving the SIGKILL signal, we can break in advance to reduce unnecessary loops. This is a clean up patch, the purpose is to reduce the execution of unnecessary code. If possible, I will remove the confusing use case in V2. Thanks, Bang