Received: by 2002:ab2:620c:0:b0:1ef:ffd0:ce49 with SMTP id o12csp1532027lqt; Wed, 20 Mar 2024 06:57:34 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVd8SfkX3AsUUXaAAmtzHeFO2GtILmdpIqPf8x/a3yeYI93VkfGCYmXimO8Jax/1z2rcQ/fbzqMBtEa8cNRrxne8f0JLqdDo5xomJu8iw== X-Google-Smtp-Source: AGHT+IFug1X8VhSjsxFFoMXb4GeNhbsq3dZDM00BS/Vv8iMcHCj6LDYp5ZeKgBNEyCm4+keL4Fyo X-Received: by 2002:a05:6a20:da90:b0:1a1:2f18:22bc with SMTP id iy16-20020a056a20da9000b001a12f1822bcmr19592322pzb.12.1710943053786; Wed, 20 Mar 2024 06:57:33 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710943053; cv=pass; d=google.com; s=arc-20160816; b=0irNuIhd86SdotfXrG3E4vNOGiUKlr70zj/1m5qLWTCjIFA8yVaG6i4tyT5fYo0tX8 EuO0c3pE/z+ekGMK+NA6chJeTVMkY6isl9oOCYDNnffKsxT5RjYZLc1iWwL7Lr1h/ydK iqyXgRnN6yxiD+qSisq+gAmGTagW086WVdIwrYnOZxxyATYgGJueotLgfn4vwxDh2x1Y iNsq34qT4ZDOlhImtXylP72eTB6x/Nx2wo1mUsh0t7Ckmd3kRiV0OmW79VPfWRgRsoMx LaYVgSqaX5eJ8nutesXrcgcRSJRerr7WryLoqE/2YFxqW1HUSX33D7WanGrCj0xix91p unWw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=UsnWJnv4PHU0fEyJ7dCOOBwqvNw/0qXbGlKQbnDQ2l0=; fh=EatWRA+kWOkGGma4xICrb5bPxHeCxy/gAUSouUxAN9A=; b=tdKfIOTLW9SOVpV1zh7NO0XQqTf0lE/H1q6vYCo8mW800Bvrb8TYGGuJAZqPkNSpIw Goe0Tw+j2vrVtpeCO4gxstNpjlp+XXCgjmo//kDa8DE1qSj51s6N65ZYhT5ybSelubDt XrV5H7jVQIv/+aqAtf3siLqIZwTdXx70wJFmS8Y13z5KGdnXa/UW65dMT6dzsJVpFN/I V3BkoIm/plBwoo6MzSKc6meNJ6pxu23Fire/H8V0DNC6QzsGqJaVCNghRDRTjt5Cf7J8 wTotVJFb2lXvMNzO0Yvwz+lkTTQVVrZOoyPFwLCo93sKcx6vfJ6MmVeqFWaCbtVFHvC2 ZQAA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-108977-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-108977-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id n10-20020a63590a000000b005dbf27229edsi12429084pgb.290.2024.03.20.06.57.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Mar 2024 06:57:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-108977-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-108977-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-108977-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.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 747BE286EC4 for ; Wed, 20 Mar 2024 13:57:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F2D4A4206A; Wed, 20 Mar 2024 13:57:27 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E76183FE23 for ; Wed, 20 Mar 2024 13:57:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710943047; cv=none; b=pO3jltS7RQIu1Ks8ct29MDQGuuN2a3EiFvV2ekZErJSnuN+Aiz3oUknJkGK5mXc7gLMEoIXwgM+B1JGhq9UAlq7toJfMeWCWWHY5eNSzw8TZNYFbgjwuwFQl1ZtULBCWA9mj6AxSGfhQxkiZDgA7SHpufXQnMnJo7mui/iw1ViI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710943047; c=relaxed/simple; bh=kHPz1EElqflbe3FM3dpaHqlVoQzEWqMlyaZlYH4LXDc=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=KojdiNtARtw+wwG7CB6EEEkEs5ONZFDocMpkgqSwubJgDLqPwW7F9amx6HGC7AmiVUhjvd/u/VWAep4Kb+x5REM35FdZekd8lEZ8Fle/ffxMp9KETTjqHYcjPCnmsWfWvGV+72HIvezMKu9e/uq0cpwrYb1DbcuNMmjaDAjnLck= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id C7C3A1007; Wed, 20 Mar 2024 06:57:59 -0700 (PDT) Received: from [10.57.72.78] (unknown [10.57.72.78]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 3C1B83F64C; Wed, 20 Mar 2024 06:57:22 -0700 (PDT) Message-ID: <9ce7b66f-f84e-4e94-863c-2f02dcff4bd3@arm.com> Date: Wed, 20 Mar 2024 13:57:21 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v4 6/6] mm: madvise: Avoid split during MADV_PAGEOUT and MADV_COLD Content-Language: en-GB To: David Hildenbrand , Andrew Morton , Matthew Wilcox , Huang Ying , Gao Xiang , Yu Zhao , Yang Shi , Michal Hocko , Kefeng Wang , Barry Song <21cnbao@gmail.com>, Chris Li Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20240311150058.1122862-1-ryan.roberts@arm.com> <20240311150058.1122862-7-ryan.roberts@arm.com> From: Ryan Roberts In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On 15/03/2024 10:35, David Hildenbrand wrote: >> -        if (!pageout && pte_young(ptent)) { >> -            ptent = ptep_get_and_clear_full(mm, addr, pte, >> -                            tlb->fullmm); >> -            ptent = pte_mkold(ptent); >> -            set_pte_at(mm, addr, pte, ptent); >> -            tlb_remove_tlb_entry(tlb, pte, addr); >> +        if (!pageout) { >> +            for (; nr != 0; nr--, pte++, addr += PAGE_SIZE) { >> +                if (ptep_test_and_clear_young(vma, addr, pte)) >> +                    tlb_remove_tlb_entry(tlb, pte, addr); >> +            } >>           } > > > The following might turn out a bit nicer: Make folio_pte_batch() collect > "any_young", then doing something like we do with "any_writable" in the fork() > case: > > ... >     nr = folio_pte_batch(folio, addr, pte, ptent, max_nr, >                  fpb_flags, NULL, any_young); >     if (any_young) >         pte_mkyoung(ptent) > ... > > if (!pageout && pte_young(ptent)) { >     mkold_full_ptes(mm, addr, pte, nr, tlb->fullmm); I don't think tlb->fullmm makes sense here because we are not clearing the pte, so there is no chance of optimization? So planning to call this mkold_ptes() and remove that param. Have I missed something? >     tlb_remove_tlb_entries(tlb, pte, nr, addr); > } >