Received: by 2002:a05:7412:d384:b0:fc:a2b0:25d7 with SMTP id bq4csp15814rdb; Wed, 21 Feb 2024 14:12:08 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWmvizjZ5AKksv8oOLNGhBQ6P7fNASoost9alIxZLMM/GsN4c+A3X0pTIa+jDILZ919c3rqr5oNiAy4tIO7FSJTw7q0PyVpf3cVaCxjbA== X-Google-Smtp-Source: AGHT+IEXOLdWYVrxN+JL5SlzX/+7mo9Q8jumaUjlxzfMMM5EXRLma3BE5xGhQkBjhB9iZPYrgjfY X-Received: by 2002:a2e:9993:0:b0:2d2:3820:fb4f with SMTP id w19-20020a2e9993000000b002d23820fb4fmr6415935lji.12.1708553527906; Wed, 21 Feb 2024 14:12:07 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708553527; cv=pass; d=google.com; s=arc-20160816; b=gA9bpKd6i7TdsASn4/Guu+Y4k5Qr34OxC1FMyIlnjO8Dhbs7qNtVVQCqGm+i5OuX1d 3Qm9xKWTGsGDIZ3E3/d5OCztcYTYZkHAYhFccdgHS1ONaq+077r71q6cEAowmZwFH7eC FSu5sMtArjizfEytcQCXJjdnqfYqtdZRARqDRYrymzjyq8hbctmoYm7DezJ/g7MLj0vg mqKK/gALY5u+oQCxjvCM+CTs6BwKwkZyfTaDXFmUCveqYIAag44t4A1z5GDDMVKAYCbI iLU2tfy3kNP389A5wwv3zrBABBgZ/u5EuO0j0TYZrIhI4AH5oOUO0a0R4/kiDVIwzr+y t4bg== ARC-Message-Signature: i=2; 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=2d7uVvKN+LoalBGOWxlCwwPCicHBRmXZZJ546EfyRKw=; fh=0CM2o10zmkJU/YmpbhLCiGhwRrHaueOZ1rVYXLulIm0=; b=eTREw8ZHc3VN175E+CH91c6voY3s7sSazzWT8A+XuLgWqczvR1BatJoEsaNVCksSPR 1+dQtPDgix4lOqn/a9j5PgNXhk9csiG2C09ylV3RIP48DKRrz/pwfBVNnJqRYrKd7dhm FuupCxoPnmvottF/+d5SN5F3uh7u13w8xESbIKiiHlf5i7cSEOIoJYgYcybNN08zh4Xm /oDwSD/su+jVkajeuC/pEB2fT0AKNcKzdqTXTCTMNnhJ0LSpOpoBJ1I2YKU3Cm8dHGRG R9ShXFrdMn0vvvooupchZp1p+Z+x/cfFwdTUGgMu7y1uIIPGlQzN0gwqXzFBCnI01rLZ tl6w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=u7udHJWe; arc=pass (i=1 dkim=pass dkdomain=linux-foundation.org); spf=pass (google.com: domain of linux-kernel+bounces-75590-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-75590-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id f26-20020a50d55a000000b0056445cfa1a1si4038032edj.519.2024.02.21.14.12.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 14:12:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-75590-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; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=u7udHJWe; arc=pass (i=1 dkim=pass dkdomain=linux-foundation.org); spf=pass (google.com: domain of linux-kernel+bounces-75590-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-75590-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 am.mirrors.kernel.org (Postfix) with ESMTPS id A1C8F1F23F09 for ; Wed, 21 Feb 2024 22:12:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 82AC6128385; Wed, 21 Feb 2024 22:12:00 +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="u7udHJWe" 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 6B29883A1F for ; Wed, 21 Feb 2024 22:11:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708553519; cv=none; b=VaEplbXy4YVEPxorInVKAm5mJUe/afkLN52WHirZoSxRA1kT7IoMs2ftyyWgCQ7IM2eMMe4VXDS3o3rFhNIbyUld1o05lKGn9vbh0B8HotLxKXAThjxgOKkxk5kPYu62NIga5pr9x/G2ZjVUrDYM99e+1TuU6TRyflIfWUR+N1U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708553519; c=relaxed/simple; bh=MpuFyYpFGbhwPH3WeRDv8S0Vma53RRU34+TszDKayw4=; h=Date:From:To:Cc:Subject:Message-Id:In-Reply-To:References: Mime-Version:Content-Type; b=ZXuaWrQdoZVGTsOFJe0gRxKKXxubEOiG2/wCqK7RWf5o+d8mMEgF/moywR+mh/HXxrj2agUsDkftT6bbqU60qCpuYtWADqWywQ/+LAiov5NGdDX3wdtiADLayGC2GNdQDxwClEwVTJkrWbQ7o3efxDmJ1o1h6+ZD7Qkq4BaUSdI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b=u7udHJWe; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 936BEC433F1; Wed, 21 Feb 2024 22:11:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1708553518; bh=MpuFyYpFGbhwPH3WeRDv8S0Vma53RRU34+TszDKayw4=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=u7udHJWeb4Lxq2B0dedbNkNBduktONYRoy1qUKS3shYfrrB1Tto8nzQhCkK/CgzGG 2N6HZCRpqLVVuIYQUEkPkzZzevfnV0Ej2LGiKTttHjW2zfdAAcjUQ4cWxR+P1I/cJx SoHUXJnoMdCBtrAvLzJVxe7oK5Rop3s7QihEVv14= Date: Wed, 21 Feb 2024 14:11:58 -0800 From: Andrew Morton To: Lance Yang Cc: mhocko@suse.com, zokeefe@google.com, david@redhat.com, songmuchun@bytedance.com, shy828301@gmail.com, peterx@redhat.com, minchan@kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/1] mm/khugepaged: bypassing unnecessary scans with MMF_DISABLE_THP check Message-Id: <20240221141158.8217ff2caf4f86c11a430058@linux-foundation.org> In-Reply-To: References: <20240129054551.57728-1-ioworker0@gmail.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 Wed, 31 Jan 2024 17:30:11 +0800 Lance Yang wrote: > Updating the change log. > > khugepaged scans the entire address space in the > background for each given mm, looking for > opportunities to merge sequences of basic pages > into huge pages. However, when an mm is inserted > to the mm_slots list, and the MMF_DISABLE_THP > flag is set later, this scanning process becomes > unnecessary for that mm and can be skipped to > avoid redundant operations, especially in scenarios > with a large address space. > > This commit introduces a check before each scanning > process to test the MMF_DISABLE_THP flag for the > given mm; if the flag is set, the scanning process is > bypassed, thereby improving the efficiency of khugepaged. > > This optimization is not a correctness issue but rather an > enhancement to save expensive checks on each VMA > when userspace cannot prctl itself before spawning > into the new process. > > On some servers within our company, we deploy a > daemon responsible for monitoring and updating local > applications. Some applications prefer not to use THP, > so the daemon calls prctl to disable THP before fork/exec. > Conversely, for other applications, the daemon calls prctl > to enable THP before fork/exec. > > Ideally, the daemon should invoke prctl after the fork, > but its current implementation follows the described > approach. In the Go standard library, there is no direct > encapsulation of the fork system call; instead, fork and > execve are combined into one through syscall.ForkExec. I pasted the above into the v1 patch's changelog. However I'm not seeing a good level of reviewer enthusiasm. Pertially because of the lack of quantitative testing results. Is is possible to generate such results, to give people an overall feel of the desirability of this change?