Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp2505094rdd; Fri, 12 Jan 2024 11:26:01 -0800 (PST) X-Google-Smtp-Source: AGHT+IFLPXI/WvcpQZ2OxfhntFNezqO6ZEiXzxYmQX7x9H5q2+npW2uLCXlIjKxUCHwvPecqAf7p X-Received: by 2002:a81:9a8e:0:b0:5e8:75e2:9345 with SMTP id r136-20020a819a8e000000b005e875e29345mr1741509ywg.60.1705087560955; Fri, 12 Jan 2024 11:26:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705087560; cv=none; d=google.com; s=arc-20160816; b=G5tGHeab4vsxGS5LRdw9VbbA2vTRuhFJ9vzQrQ/5fM5aDwjq8WxkkhX+N7tGOM+WQk oacUhq7zyy1eDAtOj2plZvEhJFlIi6y0WCvV/CNuoVxsqbcIHM+B5Aoaw2PnqT0wV8xl j7wePb4fK1P1eZpO2kdYNkaGPzG4Rwgu1herWFqIZI/l8L2gwGgKELu9tETuDo66VDYG H9IUA9//F0gsOVqbP2rQH+pveeXYqiHHyE14sLbMoYyJ4eROPnlOd6HzajuDNUAhPzMl xGC4o3kWRKom50JSnv4rLDDDuZ707gmPHmSU1f3HhCm/paL0sJxfX0wqgokiE1zaQw3j B55w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=676Dq4JgswEK9w61FayWx/ynjMSfFxUUttihg+YqxT4=; fh=c2M3RAvmNkxV1CE2tX5LazX9zfInwrOsQqzht9+03s0=; b=ylJg0m/PI5RmT5oNLPMu4z5Zvtyen7EYZSxcl0kafss3Nh7G3837prRHsEQT3POBvg +DozpdaeL1LAeLXu0vA/MfWsggncXAoAqdDUpFSg+mktrm/ZN53YcywuF08yDEui6HcH mOeIGR0g81Aqri4FCkUBf5estJ2L1uPvCAnN8sIHnDpY9GY0o8gUcgQN8I9K5JLah2mi uzqWA7Mkj0l0FHbuD+BNtMfAZOa79sYdf2cPSVfvScAR/He7nXKv2tj1oa2SNrm6EUud KYbasDlVsPdN6cmDS9ymO2/wHNnFbbJCL4KnL81lhcH5z127xiVWJC566bRXZvtKILb3 +MNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=j1gqicPf; spf=pass (google.com: domain of linux-kernel+bounces-24997-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-24997-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id f19-20020a0caa93000000b006805ccf4b5dsi3437909qvb.338.2024.01.12.11.26.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Jan 2024 11:26:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-24997-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=j1gqicPf; spf=pass (google.com: domain of linux-kernel+bounces-24997-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-24997-linux.lists.archive=gmail.com@vger.kernel.org" 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id B2ECE1C21C73 for ; Fri, 12 Jan 2024 19:26:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 558CB15E98; Fri, 12 Jan 2024 19:25:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="j1gqicPf" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 7BD2E14F63 for ; Fri, 12 Jan 2024 19:25:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C58E6C43390; Fri, 12 Jan 2024 19:25:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1705087551; bh=zj+wrk3JU3+5ZfvCnM81nr4JfGpcqQFEcx5vMnuF40Y=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=j1gqicPfwW+sqefG8tW1Y9VcYwQbES5rX7TWVmY5AlkUyNYYYqX90KBWlliAONQJs VqHG2D46bPlY9nGlAx6JP1QINnzPrJeiI5vUUMwh84Udom1UxjTxG8jPMZA3T2A+2k UonS7vOhpRtg7zrwf9X/LQ5GKX/dIG/KO6OCJ+Co= Date: Fri, 12 Jan 2024 11:25:51 -0800 From: Andrew Morton To: "Bang Li" Cc: , , =?UTF-8?Q?"?= =?UTF-8?Q?=E6=9C=B1=E8=BE=89(=E8=8C=B6=E6=B0=B4)"?= , "Yan Yan(cailing)" Subject: Re: [PATCH] mm/compaction: Reduce unnecessary loops Message-Id: <20240112112551.bbc9d5114fd2c6fb421fed2d@linux-foundation.org> In-Reply-To: <20240112073524.80724-1-libang.li@antgroup.com> References: <20240112073524.80724-1-libang.li@antgroup.com> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit 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?