Received: by 2002:a05:6500:1b45:b0:1f5:f2ab:c469 with SMTP id cz5csp479231lqb; Wed, 17 Apr 2024 02:01:40 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX1PEherwu7gxJPn+Ntn1mszufWWTely6MUcjVRGsUIXa/YwO7a5XXMgCqchR7elNFaniOC9itEW68PDScQUzNT/up9H8R/8YhI6Qm10g== X-Google-Smtp-Source: AGHT+IFXZ3tciLRq5L/lcLpsmOPRAbY3wYaaGu08OOiJtswobzbyHDFeBs8r8tXwqILYb+aUzRKW X-Received: by 2002:a17:90a:ea13:b0:2aa:98c0:1268 with SMTP id w19-20020a17090aea1300b002aa98c01268mr6149815pjy.0.1713344500628; Wed, 17 Apr 2024 02:01:40 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713344500; cv=pass; d=google.com; s=arc-20160816; b=pdTz2eT3ZzgqfMXSCI32gz1OMtnZUTlPGJp6rcMmigi0Q5kn87IsaYR8bx5Qd9iqEw ElOZ07mj4ugPEtv4oOsdFSrBEsor6KoBLFYGzrsAA6aE/ueCDAkAHYPI2dMUWziiWJ3j +N0N8h/SpgNsbza+pMHjuswAlNlaXgbIjo3IAiRrdWQvrSDMowmllUZqX82nEnef8347 7XnVBAx81LJImziuQxHE8Mn/dCzFT3yLiDQ86rivt+65U15cSgTlALCzbC3TJ8o2PV3d XdcZR3ViZEEMV6P5ljFAm2ng09N2CGwNA8uLPQsR93UhI5KOOXBpfqaSMv7/8t+L+Hez tOHQ== 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=1IQPpzwWcfVU7n9t+qjpbVgRash+OxFdYmO+ZwvUXnE=; fh=NEyApYWXohGJGX/qN/TxSn2mG1WlLjo0GuXxamL1Lwo=; b=acMJniwiYNHXUkEHwke96lE6uSdbHHPTTBcWKEEiDE2RY6B/cwNP35G00odh7Bx8ih FO+hsCXkYuse1Rum8uNx6oQO+KQuN6sX7i/3qoNIzW5Je0DfKifBpYdA3iGTU9Jtsfay +RU8seyr9cQjdyiKRbuoMqzo1JfFfYDBASHDO0IdNZ1SIv7yE7KMdpsuWTJqx2vgavLH 7jSHmxs+Bg0FvX1KyEFVOxexKEzIx796R8bffdIes1O+QCbRbYYIBbrJfCki14jNVt4j Zwdl/oQEd33xMHG0ffrR05R/GWTCRA2OcFvksrSKqKewL4EpbdNV5Ak7hYue5nNsHHqA hmbA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=KLrHvtZJ; 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-148197-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-148197-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 pg17-20020a17090b1e1100b002a2414bfdd8si964701pjb.164.2024.04.17.02.01.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Apr 2024 02:01:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-148197-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=KLrHvtZJ; 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-148197-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-148197-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 544F72816BB for ; Wed, 17 Apr 2024 09:01:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8750912A174; Wed, 17 Apr 2024 09:01:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="KLrHvtZJ" Received: from mail-ed1-f49.google.com (mail-ed1-f49.google.com [209.85.208.49]) (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 41937E572 for ; Wed, 17 Apr 2024 09:01:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713344493; cv=none; b=kQflJpMOWzhG3rn7fSUZ2uGcpW6ieZooVCcIkZL6UJ1ipJQ+1Rn4xb6D5hYutRTXN6meInczddLewSTLFEBx4X3z+4//M4KuykfsnQIz6gkVP3hZFgevFfBHvCdDGBezCBKDJ8gnIk8pTA5/5z52ypkAraNeKVq/c2eblQqvMvw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713344493; c=relaxed/simple; bh=yBuw1CTzxTdo9os+sgXjpeYRcWGrtFbwBzfIdKhm0bE=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=BQ7o1Qce1w2NrtS18TE9Y4776XY2P7mgg4hRq2MmpcAbJHR66YjZvGYU6JS0c1lUGzEKLQdJ7UdQ0zDpkKuR6C4Y/YPU8NhW40FJyh55KhufaBcDaNGZlDnxn1YGSmz+eJGq+oIzcVb5R3NsRpVefqU2KaylpGJnEHU7YEbQqKY= 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=KLrHvtZJ; arc=none smtp.client-ip=209.85.208.49 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-ed1-f49.google.com with SMTP id 4fb4d7f45d1cf-5708d8a773aso203317a12.3 for ; Wed, 17 Apr 2024 02:01:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713344490; x=1713949290; 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=1IQPpzwWcfVU7n9t+qjpbVgRash+OxFdYmO+ZwvUXnE=; b=KLrHvtZJXD2ryFb9SBN8kqeq6hiQnsjFZM78SLWVUSvzjBQRJGsUUhSYtbItNeG/My NTAdDVSONy3XU4wa/ZxpHNM7puvvUK2az4bI34BUCC9EZ5VPLptg4Q641UATYTVtc+n7 8+x0X2A522aEeToC0KkFQU/o11cNw5PG1iM+OP5IMePycWGWn9Kb+0J4S+kVzqsOi5ig /UoJgYMZ2CoycdZJTg2PNQyw5ukcNKPAV0A6Sbr7cfQY+AkJQvv+ZfTiAgfS23mRssHA TeHXvaHee4fpXq4lS2S/walgMR8G9BY3TQTq2Ieg2hF4mZ6nmF1G8HfkYBqR4I+uBUSx o2Tw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713344490; x=1713949290; 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=1IQPpzwWcfVU7n9t+qjpbVgRash+OxFdYmO+ZwvUXnE=; b=kRALJOGWAQJ31h7Cwr+wjdtww8uQxZ+enp/ArD1PI+3PVDaEWewFEa3oFx/+Bx7FUP SGX4PWqzHsz+BRhu8PLTqzotFVaZ/6As+WpWAWClsBID91xuM5hqKyszs8kh7h8oL7HG 9CzDaVArqGG344O+Gw7fuaT+wrsatpcJwQUOhxglRk8ihqmhxN5suqa0mWPu1V8lYZTu JuCxk7CoDmA+Wz121fvlfwDMk9NLB1jd1hKZgkQVwttXJpCUit1M1ljAJ8vTi94AdSWg Fd4hvj1kbweEWTiPd85hyvcKGMOa2jAheQ38pKRzTFVzsZvNtcD0BTbpLziJdfKz6dXt 5mtw== X-Forwarded-Encrypted: i=1; AJvYcCVMh6xcjMOlrwRO9MnP6xlwWKJju6zwrgV+Uy2Ag8d54rQ0u5wB6qOpMppwKYlXOa7+K5N0W1oxw3Hvzi3Qk3kCk9xYkKZY67hYZRhp X-Gm-Message-State: AOJu0YxUdB2/oXdXY71ycbV8KXL0tgtUSOzXQCtm9XREsrcrAz7mdc0c M3mbCKG/wIlv0CW0B+7KWtPJfUdiCeIPi2b3SjgrNFJmw3XS1a0OFMbISCXH5OcaegJIysJtXUg 9c+ticXN9kOMzn41h1HfvF3Omz1s= X-Received: by 2002:a50:aa9c:0:b0:56e:2ff3:bb89 with SMTP id q28-20020a50aa9c000000b0056e2ff3bb89mr9695343edc.28.1713344490228; Wed, 17 Apr 2024 02:01:30 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240417050426.66194-1-ioworker0@gmail.com> <76d22c08-82db-4ea8-a7cd-c77589e132e3@redhat.com> In-Reply-To: <76d22c08-82db-4ea8-a7cd-c77589e132e3@redhat.com> From: Lance Yang Date: Wed, 17 Apr 2024 17:01:18 +0800 Message-ID: Subject: Re: [PATCH v7 1/3] mm/madvise: introduce clear_young_dirty_ptes() batch helper To: David Hildenbrand Cc: 21cnbao@gmail.com, akpm@linux-foundation.org, fengwei.yin@intel.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, mhocko@suse.com, minchan@kernel.org, peterx@redhat.com, ryan.roberts@arm.com, shy828301@gmail.com, songmuchun@bytedance.com, wangkefeng.wang@huawei.com, xiehuan09@gmail.com, zokeefe@google.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, Apr 17, 2024 at 4:19=E2=80=AFPM David Hildenbrand wrote: > > On 17.04.24 07:04, Lance Yang wrote: > > Hey David, Ryan, > > > > How about this change? > > > > static inline void clear_young_dirty_ptes(struct vm_area_struct *vma, > > unsigned long addr, pte_t *ptep= , > > unsigned int nr, cydp_t flags) > > { > > if (flags =3D=3D CYDP_CLEAR_YOUNG) { > > for (;;) { > > ptep_test_and_clear_young(vma, addr, ptep); > > if (--nr =3D=3D 0) > > break; > > ptep++; > > addr +=3D PAGE_SIZE; > > } > > return; > > } > > > > pte_t pte; > > > > for (;;) { > > pte =3D ptep_get_and_clear(vma->vm_mm, addr, ptep); > > > > if (flags & CYDP_CLEAR_YOUNG) > > pte =3D pte_mkold(pte); > > if (flags & CYDP_CLEAR_DIRTY) > > pte =3D pte_mkclean(pte); > > > > if (--nr =3D=3D 0) > > break; > > ptep++; > > addr +=3D PAGE_SIZE; > > } > > } > > Likely it might be best to just KIS for now and leave it as is. The > compiler should optimize out based on flags already, that's what I ignore= d. Got it. Let's keep it as is for now :) Thanks, Lance > > -- > Cheers, > > David / dhildenb >