Received: by 2002:a05:7412:798b:b0:fc:a2b0:25d7 with SMTP id fb11csp184428rdb; Wed, 21 Feb 2024 23:43:39 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUv1q2jlHfRraQkp6jz+aeoHKy/esbJY9WzHCLdoonVQA04w+I2AkxoXpYY5lHJm4FTPYbldNH7oo7XT+m9P4jALeFvos3XXL+T/Tdjpw== X-Google-Smtp-Source: AGHT+IG+VKm5P8aEz1/TwuhzMghx/pt7jZThHG3SMJO619zZDj2IftYI/so8T9cfN/f/4QpP3Uba X-Received: by 2002:a05:6a21:8ccc:b0:1a0:6f51:edee with SMTP id ta12-20020a056a218ccc00b001a06f51edeemr25465782pzb.56.1708587819461; Wed, 21 Feb 2024 23:43:39 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708587819; cv=pass; d=google.com; s=arc-20160816; b=lLROQ6g6n/gXhB6XOKXn0Vg2dXmaysXUNm7T/Oy1jsxU7EnaQ1JN/2YRtROLssXaYt Pu6ubqMwXO/x2belYp3aCQWHYoFsQCIxTIAxs+byMHuFzz/v5akFsUTpCuv4n4PoWVL1 vyjehsZAK9RjR1dHVQYpHC5RRz/fY39Ynm7l+Ao3XlXdChfzUMsHS2byd3eEnvAKcAY/ BpSIjlnWP9ZXvuhev6mbZ+sYdAtbS78eNd02bSQMrUN+V0dBqzHUFkFZyp0PYZZTZ1h9 ddoMxKTvHwuGsyVe/C4kwhEmUFvnU1/8c9Q9mFzIX9hi5PjVB2wG2E+c9ro7bad35Ads 0Erg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=9sqllwmMdInDIe20Q1qFJaLb0vW0NHDiyKJEVgWyWzI=; fh=YZ5/CItCsZyAzo2wmQz76YLMQumjQ8j5T0wdVT04/G8=; b=n5NGLB+2Oaev2zaQG1bs6+yJRMw94V7UZnr0HXhTNeinbQJF0iIkXYtOuU8nCIq+GE SnAjlUqv9l2Wy3ua5oSW5xPpixktyriNuV3/C3XsYceeOGEntAGSRAm5ejDp2i3eQHtE N9X0MKOwu+IGg+6o+ocyrk//feUS4BS0yrLBKNKXKNDRTKKeVw7+yfaBX5rmZKeDwse4 xoygzOYEUulXdUQUrnwL3O18YC20n86uCumwzQ1hK7YJSZsqN83VTt6ZJEdFbDQohQZ9 T+X1uckvFGTyqjL6BYlNxUlrGkiTsHN9bRRxYXROhn4sCDMp1juWcTGpiYwL4DVjOJjc gQ+w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=cqmMrrn5; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-76019-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76019-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id g15-20020a63374f000000b005db652f1ef0si9878842pgn.545.2024.02.21.23.43.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 23:43:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-76019-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=cqmMrrn5; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-76019-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76019-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 2D134284CE7 for ; Thu, 22 Feb 2024 07:43:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 06C411799F; Thu, 22 Feb 2024 07:43:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="cqmMrrn5" Received: from mail-yw1-f182.google.com (mail-yw1-f182.google.com [209.85.128.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A9A46D533 for ; Thu, 22 Feb 2024 07:43:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.182 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708587814; cv=none; b=dCM3PwC2jWKY/ky15EKIvVPS17dBRTCTAJfebvBs4XgHAsoW/fn67FxEkLIExOXZAclNAaR6br6pSjQuza8BPmVVMYd6Rhocw8QRdnPUFx2/xHay/TvD7/92/N6r21hz1g3fdzohjWTGIqo3c7d60RAhfGxcedCheeaXtbS23mc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708587814; c=relaxed/simple; bh=J+Of/Gb6IOHr6IVoZzbj9HFtwypj+rnvHcCQgqMqG70=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=G5hymsDoEnt8B25bIlNxFF6tcxttCOZjzmGsudPzU0zGtTT14qCqK8e/ZMRh1htgkuqfGS45ZsD5C99D8h3gTsUZkTcdsuE8svrI+wTtTa2gpJraSN057i+hM6NmUct1Bh22bGfeoJZxzU5xGac8NaeBZPfkmpg+81TE4jRLq48= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=cqmMrrn5; arc=none smtp.client-ip=209.85.128.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-yw1-f182.google.com with SMTP id 00721157ae682-6079d44b02bso55352937b3.3 for ; Wed, 21 Feb 2024 23:43:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708587811; x=1709192611; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=9sqllwmMdInDIe20Q1qFJaLb0vW0NHDiyKJEVgWyWzI=; b=cqmMrrn50ujNZoy2VafOOqlFHPR/q6IflHRC4AKl+v9TmpaK11FN54RN3FobChmxf6 92wEq6KSFQiqrig2DHCShoN4WDKQmf7S4QU0BJHHGzDITiqGFPOTtRIHkMCPTT/836HH oqiWzbnb+7ED42gmVtXAMy0VNUiJ2OAUwAKNsCWs11qJuhZkhWEgYTlBNqHjUKJ2Pm3C LjOOsMf9NSD4W4GlGh5DLs8t4CMgVovB2FEj1G8luY5do90x5GX6K7ydc7a2mRDq+CCO anAAon2ZKslZZ+fSdJnI2UPHaOXZq9EL2oODMd9aMjuRSXnefz11yvRYVKRunXQh2F69 Cw6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708587811; x=1709192611; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9sqllwmMdInDIe20Q1qFJaLb0vW0NHDiyKJEVgWyWzI=; b=qbFjgtu0m+FZ+O/Q5snfZwgtioD8wgwlZQVRxcVS47YHXDnr9Huq9vvuQ0xB0SDJB9 BRU5nJ+JTM0pj9WCKMmCVfrQI2PS6AJNcZUUqfGnEJsDsEFI/wh2iSir4ynWW1xUktdX i9NhcN8Pu/UDP9V28OKl+sjfWx+KHGCvGQJlMrROyQSSFfAQDh+DFZpKkopKeXRhMdO6 2z52FHfGPIuUtnrZHP204+9BwZTLfg2dB+FyRjRISs47FOlIfR2izvWn3/+kRpQVt1KG 13X4JFBNp8xg04k9a8/EKwVsp13mcFAKo47Ul3XaIo/CF5DrDPFAo0NsroPkH2uoIWwX 1Yrg== X-Forwarded-Encrypted: i=1; AJvYcCVXYx/Mb4ojTPke7ZjEIGqMXgWAj1TywtIU1mXg1SpqTkmz6EggouJHWwrfONKNASFApuQpQE0jJSKw5IpB8AZgScUQHtcuiQWa20Hj X-Gm-Message-State: AOJu0Yx8zKiYYs4fvHnGJ4KfESi4jCqZYNxmJqEVVXtTbNL1qen/LLN+ sPLFnlmsxDGRx1h2e+Z2a1nefxPm6/kWHJfXl4lH2P5aSrm08tCZj8114yka19L1uSvvDrQLsn0 VQcr53avWCCKCMqlywwxDjSr+Av0= X-Received: by 2002:a0d:df45:0:b0:607:925a:3bfe with SMTP id i66-20020a0ddf45000000b00607925a3bfemr275058ywe.24.1708587811596; Wed, 21 Feb 2024 23:43:31 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240129054551.57728-1-ioworker0@gmail.com> <20240221141158.8217ff2caf4f86c11a430058@linux-foundation.org> In-Reply-To: <20240221141158.8217ff2caf4f86c11a430058@linux-foundation.org> From: Lance Yang Date: Thu, 22 Feb 2024 15:43:20 +0800 Message-ID: Subject: Re: [PATCH 1/1] mm/khugepaged: bypassing unnecessary scans with MMF_DISABLE_THP check To: Andrew Morton 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hey Andrew, Thanks for taking time to review! I appreciate your suggestion and will be supplementing with test results shortly. Best, Lance On Thu, Feb 22, 2024 at 6:12=E2=80=AFAM Andrew Morton wrote: > > 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? >