Received: by 2002:a05:7412:798b:b0:fc:a2b0:25d7 with SMTP id fb11csp574258rdb; Thu, 22 Feb 2024 12:23:41 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXi9GbCjILigo9EWNlIE/NVcq1V/PEf9kyQvrkhBpYEcYBLTQGtbkdX1gwz5dZrrSqkXufvLEnmyMipUgKj3WTLS7PvRjtABmSy/a8R6w== X-Google-Smtp-Source: AGHT+IGwhm+RjpV3Jx4KMSp7YeWBnHCGsIcgvBGsWKsI4qRor2TwuyBcvOLo8zaKbKSW+ODj5IQW X-Received: by 2002:a05:620a:b5b:b0:785:bde7:657b with SMTP id x27-20020a05620a0b5b00b00785bde7657bmr151523qkg.36.1708633421113; Thu, 22 Feb 2024 12:23:41 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708633421; cv=pass; d=google.com; s=arc-20160816; b=PlpL5hFswGGWYtwkWFOvXR89SQpbiFeFMpcNb8idmeZ7hkcvGU6XZT+CYY/w82SZsp N4eVJLcG0j3bLfg6Nw1tKmGodrk1XP5DBHwDsmkgDqcGCQ68M4Glt52YKpbQztL9irwg K9WvHX1SBKLDUYYpx3RJHHRfUHpm6K2ZkveZTesqqVm/qiGpJ4qpKmmejz4FknhcNZxj Nmds02D3Yr5svyeXkWh0PfeTqd0+RQNKLCxlp7LXHdtO9YxX7dvalytZ/MbJP33EyW6U AMv0usu32sHhxb1/Y4194PeoNDtH1YQwO877qRln95enEVMVhh4NSo8MMSQqIyu8XHmp St2g== 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=K4zRRdKL9lsMMNiFrqHRK+mlIK8Wb18NpLnVMWick6o=; fh=d6myZ6pA0XDZOTojWcetm2NxS+qR64ShAXKRNg4C2dE=; b=P0UyHigNLyuuEe0b6wyIlQ1omegAFVDsEEJZtpjt+pvnUFZhY0Wk3nGbmSWsWsuFuI /ZLQ+O7o3ocUK84UBKWX9fOVaojqfEkleTV7M0YnwmLwEZnKoVKXKesH5xlczE6cNI/d giwcNImvCEJkgLapTNv9J0rWNUAqSZ24SnGC47enhOz3PrmajsGLWPuHQjB4yUOoFQap 1tLPIG+AKHUlZa6LsyObT2wemWdH+9AmvNMnLGTZAWCPQTcSUUK9RFdUhG/+yhzA5F56 nJvxJBP7gIwhTkPP7pHGxqPT3mLp8Zh5vDNYwjuKjmyxb/4dYwHPPQx582XoZVA4RXah +74A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=OPQUVRXh; 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-77312-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-77312-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id m8-20020a05620a214800b00787aa53655bsi878411qkm.262.2024.02.22.12.23.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 12:23:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-77312-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=OPQUVRXh; 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-77312-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-77312-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id D398A1C23099 for ; Thu, 22 Feb 2024 20:23:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 45D1C6E5F5; Thu, 22 Feb 2024 20:23:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="OPQUVRXh" Received: from mail-pj1-f42.google.com (mail-pj1-f42.google.com [209.85.216.42]) (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 246A514B81E for ; Thu, 22 Feb 2024 20:23:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.42 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708633415; cv=none; b=PozKwQIWs0AZVxY+pnW164nqvjdwwqXxbciMIg8F4h9a6l7Zdxb4Kk+4lVa8eWkc9VGPCUUe/1eOftspf0mFlX5yzZwsGJXStEoYAds103xp9yMI2ui0qnk2w1TBFv86ytURkCPKkd87MEnOK0e14ALv0+OO2z7GizgNsP9y6Rk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708633415; c=relaxed/simple; bh=4fRBgKaN3slJsS+si0oakQ81lVv2fxpNPglrqvJUjmk=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=DXLc/xtrhCVD68U3opmswPsh9KZTDaR2HfhYYIMgGsqOiR4C8/DN1QeBTg3upBtYPM4PiFky8+dm22WUXtKRGKMw8/WHjQkdlVWBhmY5JYxcX8tLJ5qP4/XEOmCB69bLW+sMoS9mjUurRFbz5HwP3Y1x97cHIxUUQkx1edfqhmo= 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=OPQUVRXh; arc=none smtp.client-ip=209.85.216.42 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-pj1-f42.google.com with SMTP id 98e67ed59e1d1-299a2456948so192430a91.1 for ; Thu, 22 Feb 2024 12:23:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708633413; x=1709238213; 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=K4zRRdKL9lsMMNiFrqHRK+mlIK8Wb18NpLnVMWick6o=; b=OPQUVRXhjKjTnYTK2k/nV44Obfd/oHhReRXA/1mOUsqDyfrAhdD/9tE5N05A1azN+D N43pP2LJJR51xu4Csg9GSzPYVxy6Z9cfoji2n5m5SPBNv6QQ0bNzptQ6toTor1mk4CQO KW5g2D5F3Vn7zF3pgaIZ/RpJrrc+QO7lt2kVe8toT5IRpG6XznSAjjgmJptCnMRppPmL PPrwhyfj4khFQR+breOkhlZcwG+0AW3eDX+p8+iyYosBFg1oC6oHAqkLu6EH+e7VFIBb JBt1niv7UKxrV5WdDcZTQP1P29ncGVQMYnH5hT98DD1857QJJK5hJRhkro6c4/EMDz1c nVyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708633413; x=1709238213; 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=K4zRRdKL9lsMMNiFrqHRK+mlIK8Wb18NpLnVMWick6o=; b=iSbs77uo1OzSe80AkLpeMp46ZuxkNdZyfOZDejbXHGu3IaUMZTsubBd4292BbSv8s6 qYPd5d0IoU0b78PDeDHKocmMtvpr04z3kPbBg+8bKXZVsXqgFEsYiReLApHyzgaY6V+P eZ2VwN0JbnIH7N3yZaokabQXUWWAEozrmpuLZHZS9NbEFhi54unUofsXQGYDgJ1NjMrr XmNTdOVGLl3fXB0AFfDbHAdPyJ2RD5FoEfVsYG4hHRnp41thpXhPSiCKSCNvlBzIp/Ev bf8p7wea08x4NHTmbDDd/S5PNvjdbWNYWfWZv9yUyPlMK0Qve67sLrYo1ihYzoIHx1Aq e8xg== X-Forwarded-Encrypted: i=1; AJvYcCVtVVz6Te1Z15wp4z1e85ytZapZsdrwhX1wu9+yvhX9ilz9eO+e9mXUZOEH7cIciRpFJ57zpue8Z2Q6dCBshOg9al248TNWFHGLNYOZ X-Gm-Message-State: AOJu0YwFNsxonG5dU91YJ+BQtTgw7QsbjDGMSh+TYqKETLX1K7A1xW2k yqysDsNB+6a6fCB18KhHOSYQwh63IOhLP3ZQ2kkkgXjNRfri8I0YjmPRy7dW3/gRAvHINdamgBm zJKV3CjNh+4zZ2OMf+OKpTXJ+92I= X-Received: by 2002:a17:90b:b01:b0:29a:4300:e2c with SMTP id bf1-20020a17090b0b0100b0029a43000e2cmr3476015pjb.34.1708633413413; Thu, 22 Feb 2024 12:23:33 -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: Yang Shi Date: Thu, 22 Feb 2024 12:23:21 -0800 Message-ID: Subject: Re: [PATCH 1/1] mm/khugepaged: bypassing unnecessary scans with MMF_DISABLE_THP check To: Lance Yang Cc: akpm@linux-foundation.org, mhocko@suse.com, zokeefe@google.com, david@redhat.com, songmuchun@bytedance.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 On Wed, Feb 21, 2024 at 11:51=E2=80=AFPM Lance Yang w= rote: > > Hey, > > On an Intel Core i5 CPU, the time taken by > khugepaged to scan the address space of > the process, which has been set with the > MMF_DISABLE_THP flag after being added > to the mm_slots list, is as follows (shorter is better): > > VMA Count | Old | New | Change > --------------------------------------- > 50 | 23us | 9us | -60.9% > 100 | 32us | 9us | -71.9% > 200 | 44us | 9us | -79.5% > 400 | 75us | 9us | -88.0% > 800 | 98us | 9us | -90.8% > > IIUC, once the count of VMAs for the process > exceeds page_to_scan, khugepaged needs to > wait for scan_sleep_millisecs ms before scanning > the next process. IMO, unnecessary scans could > actually be skipped with a very inexpensive > mm->flags check in this case. Thanks for following up on this, can you please capture all the information in the commit log? > > Best, > Lance > > On Wed, Jan 31, 2024 at 5:30=E2=80=AFPM Lance Yang = wrote: > > > > Updating the change log. > [...] > > > On Mon, Jan 29, 2024 at 1:46=E2=80=AFPM 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. > [...] > > > Signed-off-by: Lance Yang