Received: by 2002:a05:7412:d1aa:b0:fc:a2b0:25d7 with SMTP id ba42csp751673rdb; Mon, 29 Jan 2024 18:15:35 -0800 (PST) X-Google-Smtp-Source: AGHT+IE8FQK/SlHKzceKUrvAjwFVKJwfE+0JEpPrhhp2kx/KuW/yGVQleNMZtvXGndb3DH8g2Xqu X-Received: by 2002:a05:6402:2792:b0:55e:f64f:d3dc with SMTP id b18-20020a056402279200b0055ef64fd3dcmr3174900ede.11.1706580935650; Mon, 29 Jan 2024 18:15:35 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706580935; cv=pass; d=google.com; s=arc-20160816; b=epvLXzpaf4BX4nSRY8blSj5kvbUHumphA75iTjyNl2mZTC/MCba/LHu6yu1wAEmvUQ rYy7GVKZdn1XCNRaKlTZ6Hj03v6IuXRYOX1bEEwlGulj3IqVdiIF3+/KBsUIfkEpUeQi jJNIyYDZ0mQr6W4LsjRPTLsdxmW+suKqGjqnkYQuiI+nYzupxESXJUrCRc9L1MR0Cao8 eLARs1opIbxX9xrwhwoDVQtN/5z6ehw8Fo0342kXyz6Urg1qixHjvtgOd7pNgwPyy7He 1hu02raMje4zcBy/gniAb3XIOOSm1qjpJdx0NVw2pvg0xIjqODcyIOZPF6Qu8HE/RgHU 2eLQ== 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=oZNQuCd+KN+iEabO/fXy/33O6CPWq/hHiiIIZfw1y7w=; fh=+LmA/NZ3YXeQtzy0/2OuZZJHr3Yy7laU9zVutxVXZE8=; b=xM8dTvcMLkljbNE9E5yCmqprkA8QKnbsx25hpmHqWErxfHLIPlPP0tIt+/xfSRSfD5 O8ZG3jj6K05ZwOXlhIgMtFhCBCWFQSiNNkUlHsMVGxw3CqIP1jr3hiqQcnXR3+oRMyHo 8oKTep+aqqQi1a6O3c5NkUmclH4WBaXMOddsY5eJAUu+wQCqUljSTBBPLKOD2gCX+Th1 QQeyzWlsJT170g3CpRWpMkl4woRO4h6L7Sj36BDR6Wa4XEjc+azdOR5y0su8VWd5AX/e H86Pfv+ANc9eGo+WYOy3ztwvpEDdAS1c6aAlfGaVGHaoW1+zVrKMgOyaNSqL1catGpem d7og== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=eTSzvIOd; 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-43800-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-43800-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id y2-20020a50e602000000b0055f3d8ffef7si198610edm.392.2024.01.29.18.15.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jan 2024 18:15:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-43800-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=eTSzvIOd; 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-43800-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-43800-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 6AF631F27135 for ; Tue, 30 Jan 2024 02:15:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8FD49364DF; Tue, 30 Jan 2024 02:12:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="eTSzvIOd" Received: from mail-yb1-f171.google.com (mail-yb1-f171.google.com [209.85.219.171]) (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 43AAD364C7 for ; Tue, 30 Jan 2024 02:12:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.171 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706580754; cv=none; b=AYppnjvqrgFTjc9MqFr4bwrtflzEAjcLOKqDbrYoUR0ItReK6s8k1JGJG9bZvQ/ktJOODMj66BNAJ4Rqp7qoLOz3s5TY6dUP5lTI0+vkW4AFMDXygOs6QVP9lRti+MtAg3wxuRJoiSQzxu6+ubP+ksXrIgDecZOWSCPXDPwB87U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706580754; c=relaxed/simple; bh=oZNQuCd+KN+iEabO/fXy/33O6CPWq/hHiiIIZfw1y7w=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=JK5iK/09aHxWMbI4657f6B61Q7z7hfvAlmNdFWf6YPVA4XlqFPjvCF0+iEYgiYrYzOHY179BRpKFlayqthnz/mxOVY/pbPWafa6hHk1enaBEjKkmVDP8Im00OumjFI77jo1M0ny/Oz4D7iX7QUSncU2VDnqA5yiAVlqGcq1hbPs= 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=eTSzvIOd; arc=none smtp.client-ip=209.85.219.171 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-yb1-f171.google.com with SMTP id 3f1490d57ef6-dc22597dbfeso4360745276.3 for ; Mon, 29 Jan 2024 18:12:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706580752; x=1707185552; 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=oZNQuCd+KN+iEabO/fXy/33O6CPWq/hHiiIIZfw1y7w=; b=eTSzvIOdCoaBGiBMzq1em/jnH+I/hhWvaboH2qNb1fXpwOHAOnhIz9973vtuMUtBYv doofVUQdnkiF/kbsKnDkJ4EhbHJmXFjc3c2AITu6yvjUIo/AzkY8+P1xGqfSOOKeeEyN hxZFxnyt5DbNAM0ffevG6kNtAl046k1sN10CvC2vAuSfyLXtd4T+2W4O7/rb6oReSPn+ SebgyXVm3XJHhIDeUgb0YwJ2PAZ9qa4kLLg29Ve5MTLygcBa61/pHwOhXsjD92Wf45Mm kRGfHf9A3vaUPTSbebpF7hm4X5u0rRxP1QmZhDFPaMx1bYDdBNKtIyNb3VMty0n2/ZoG piUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706580752; x=1707185552; 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=oZNQuCd+KN+iEabO/fXy/33O6CPWq/hHiiIIZfw1y7w=; b=fsWgND0ruRqqfO8zzv1muoqtQBka0yNSG+2GTA47YZfTPXvaRJEysr1nUT+Mu79F3s pMWvjYElD1Ue1n5kx80aZj+dBDBnPrY+MMwqTEPdjaUkhxGzUe48OTMn5dANz5t3Cjn6 F3mFoZEBKBgG4mjAdFBDkuI4LPGXtifGblLZz9fG1VUsUN8lOeQhz6/R7vxetH26YNxx 6FZX7wjpb1QIKzBlkghW2bI7IHK2DRFRosBzPxkCvalQXRRSlneP2YoxhVbB2GsCGk4B K1aHHU4ZCCVdG0SlJdr2Thq8/65evSuclQeY9erWu9bo98fkDdkXqBuZfTEGjU9O4bH2 yaMw== X-Gm-Message-State: AOJu0Yz4RtYTrNuzf8xalNZ4lmxRh5W7MDNGWl3vLuG/UzBfQ7P46BvG lXJp5bKt2gtG99XjyCY7O77MYnmhioosBcemCpUtGK2s8A/rAR3cVcbhdHkjExuTGuYDYcjEg+C r6NmIVKg2oZiLy7CbAIXNuLW4Uig= X-Received: by 2002:a25:f449:0:b0:dc6:4582:2bd with SMTP id p9-20020a25f449000000b00dc6458202bdmr5297622ybe.76.1706580752116; Mon, 29 Jan 2024 18:12:32 -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> In-Reply-To: From: Lance Yang Date: Tue, 30 Jan 2024 10:12:19 +0800 Message-ID: Subject: Re: [PATCH 1/1] mm/khugepaged: bypassing unnecessary scans with MMF_DISABLE_THP check To: Michal Hocko Cc: akpm@linux-foundation.org, 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 Michal, Thanks for taking time to review! 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. BR, Lance On Tue, Jan 30, 2024 at 12:28=E2=80=AFAM Michal Hocko wro= te: > > On Mon 29-01-24 13:45:51, Lance Yang wrote: > > 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. > > Is this a real problem? I thought that the prctl is called > on the parent before fork/exec. Or are you aware of any > applications which do call prctl late enough that the race > would be actually observable? > -- > Michal Hocko > SUSE Labs