Received: by 2002:ab2:7a55:0:b0:1f4:4a7d:290d with SMTP id u21csp525985lqp; Fri, 5 Apr 2024 00:23:20 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWihiWlpu1w/B1r3xwOKx8U8hbDtPu7xHjX1JV1PTTdPf6egy+fW9Dn8/Yr4lm6iH+lBgOHoI4OU5DQMsRMnYXrLIqqTXxuYeotsxcXCQ== X-Google-Smtp-Source: AGHT+IGjm8c75O1ZtcvYy9E91l8GFoLcMoqykbIGXac2HKQ4chO73DjzrDXs8ogy+ZQh1fVRZmRf X-Received: by 2002:a17:903:2286:b0:1e0:b872:d862 with SMTP id b6-20020a170903228600b001e0b872d862mr768325plh.52.1712301800201; Fri, 05 Apr 2024 00:23:20 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712301800; cv=pass; d=google.com; s=arc-20160816; b=PEWzM3d87xbD/RaHL68ZZe0APLWAh2xIYkNZzF6dT4egD/R35hhuTzX+XoLbzycqok GAbTYBcCPDF2771t0vX8Rm03wy5BVJPms3x8set3KQs30KhNjVG8+aeiqPJ7MrEVOa/X OiNhHb+sxk+DvapqcvEECfhhg4tRIc7A8q79whj3GHWbt+C/Hq4t3o7VKviflc3cM58U qKEMT5U1sEHL56A34fZ8rDwj6Nqs+hkYKbg3Fq+0rdFtNgttkMwaw00rJ29BT/sQz1q8 wEuH2eweKtNUCQ/FCVug0TAzernVgQdSrXwicol4LTGrBeK9vKk/9j7xmsCXqZUNA5Th j36A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:organization:autocrypt :content-language:from:references:cc:to:subject:user-agent :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :date:message-id:dkim-signature; bh=5bNmy+qfalu205HO5QSi0WdStaw2vHqHKX3BP6Qt0VY=; fh=ens4sGt10tw4CQebP7J0Qz1SiBKSbnt4E7Q1uKdhv+I=; b=hqBdPltuDBqQkS95r6uzcK0KVdMKvEuT8sFn1Shw0zAgUWSw/D7iHgniA0u7up7KGS cn2p8zQSaLKetm8bBWH45sLkOL50cjhYmMFG8SqUFeiMiACak4pwCeBDguKX1sH1DpSK ooOOhis4hQxi19K33gfHxLTnnzQMHWhratq5zlsbCkMFbl3m63n6wt0qolhiQ6K9Oj1X pNvTLLcef7GuNFx9tDzygRc8sY4CCha9qSVOBobpTIsLjqXLbZ9rf357cPwJXJf98QKf TqvtNV6gtiOwKasz0c756GjmLZfMJJ9yb9/BSPIlgGexPYW8ULGpNZQJ8i3JOchp/Raw 9yfA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=NpIAX7zP; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-132539-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-132539-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id z14-20020a170902ccce00b001e08341f80bsi887545ple.485.2024.04.05.00.23.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Apr 2024 00:23:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-132539-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=NpIAX7zP; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-132539-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-132539-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 1BA87B207B8 for ; Fri, 5 Apr 2024 07:23:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 83281339BF; Fri, 5 Apr 2024 07:23:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="NpIAX7zP" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F34E724B5B for ; Fri, 5 Apr 2024 07:23:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712301788; cv=none; b=h3jWb/h8tFVw7hkhW28O/hpUp106j95+qQMnd37wfp77xEp+j38L2kCfdFm5tohCi1NUNRlJlg0pakuUIR5m3V5yDB3tgiJSQRFQAMNFjZqw4oZAzJMP4SHrOB0LVOJ4ae6d1QXngSDDDPSXOXEIP68yFLTiAOBwPTKpo7ewL8E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712301788; c=relaxed/simple; bh=4zy5R5VMd2UQLQtDJETC066s0vkWdzxcGbp2CLkHw3E=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=XRoMOuo847zRyhBNnfgN34xGu7eOP36fXL81+cNpxpoVmhhH4IwE7zzj1soX8x5wo0mow/nReKcd8f3zxPRSNb14vKijVAQ0Jqcc3qpc6wnpGcwjohLQuFqjfwSR3TnMxstU1V9vVJWcMXYXpBO90NopLb1mJBtpiQjwACByxsQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=NpIAX7zP; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1712301785; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:autocrypt:autocrypt; bh=5bNmy+qfalu205HO5QSi0WdStaw2vHqHKX3BP6Qt0VY=; b=NpIAX7zP3n3O8y7B85sUBRZmW0r0FOnxcK7iO1tyQ/d1Ot5VcSZI274qRR9PXpCobH+5Kl pqYxjB9Xg1TuZSOspRntMRl3kNDNaqPQ38SWl4zKml4qwXLmOEpdOSVPLFYqKLZHY6RgEl YkykCWvRDA5AzRX6lvfq62M1+ROuDlM= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-10-808OqmfMM-61XwusJ2kwew-1; Fri, 05 Apr 2024 03:23:04 -0400 X-MC-Unique: 808OqmfMM-61XwusJ2kwew-1 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-343c6a990dbso642697f8f.1 for ; Fri, 05 Apr 2024 00:23:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712301783; x=1712906583; h=content-transfer-encoding:in-reply-to:organization:autocrypt :content-language:from:references:cc:to:subject:user-agent :mime-version:date:message-id:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=5bNmy+qfalu205HO5QSi0WdStaw2vHqHKX3BP6Qt0VY=; b=h0h3VDnpUVBCvDaLdFeVKGm4ZV2W4kUF+IybQZ9KbLHup9IHLd5eQ453/dO7yLWCbs /0QfwiY5rpQaPF3cQ631iCMUt5zJuOqtAi3AALOBKUfAUGVTnQfOGhggsEFBt6oNz1tQ +HQO+Fo8fzvL1DiZJSrAx0AhxUpeh6seA5tsnmCLVOGVo7pcI7CALH+eil7JaO+retmp GyPgh1k/uBn6V6LzH6Lv5H6L3BHcjwgEJ9r3MVz3TJIrmCwrm83dGajFIT2A/juiEAet 98Fp0HxpN1u+wJJp+5xauhB6OqyDDueYJCWUnT8gD2yuZOIu8QrWJTQS2OFqY2z8l8BY X8Dw== X-Forwarded-Encrypted: i=1; AJvYcCWcNn+PE14hWIoYYejfqCMzr14usGPOywMvIvY/QvdoEeEFZrfDTinpy+oKo1DqF4D4qr42rH+tF2CgW021cKDYbnX2p8ViSWU1DAnT X-Gm-Message-State: AOJu0Yzzi9w87V9StbRWNG6baVz/JLcBGCo5ntYuoZAk65fRVSY+GVDw f/rrH65wQKq+CHXBDDB9UtEI/eRQutgiJEfBkKu86GYKE7qaRuIeAFOJOLXWwun6kbbvdzugpRV OU4zgjJ9oznv3+lvB1v5eWSfThSfLvO2R+ykgfxvQmBo0PyC7rn8flkxX19vQpw== X-Received: by 2002:adf:e6cf:0:b0:343:39a6:93bc with SMTP id y15-20020adfe6cf000000b0034339a693bcmr727761wrm.11.1712301782984; Fri, 05 Apr 2024 00:23:02 -0700 (PDT) X-Received: by 2002:adf:e6cf:0:b0:343:39a6:93bc with SMTP id y15-20020adfe6cf000000b0034339a693bcmr727740wrm.11.1712301782620; Fri, 05 Apr 2024 00:23:02 -0700 (PDT) Received: from [192.168.3.108] (p4ff2306b.dip0.t-ipconnect.de. [79.242.48.107]) by smtp.gmail.com with ESMTPSA id i14-20020a5d558e000000b003434b41c83fsm1288994wrv.81.2024.04.05.00.23.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 05 Apr 2024 00:23:02 -0700 (PDT) Message-ID: Date: Fri, 5 Apr 2024 09:23:01 +0200 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 v3 07/14] mm/ksm: use folio in write_protect_page To: alexs@kernel.org, Matthew Wilcox , Andrea Arcangeli , Izik Eidus , Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, ryncsn@gmail.com Cc: Hugh Dickins , Chris Wright References: <20240325124904.398913-1-alexs@kernel.org> <20240325124904.398913-8-alexs@kernel.org> From: David Hildenbrand Content-Language: en-US Autocrypt: addr=david@redhat.com; keydata= xsFNBFXLn5EBEAC+zYvAFJxCBY9Tr1xZgcESmxVNI/0ffzE/ZQOiHJl6mGkmA1R7/uUpiCjJ dBrn+lhhOYjjNefFQou6478faXE6o2AhmebqT4KiQoUQFV4R7y1KMEKoSyy8hQaK1umALTdL QZLQMzNE74ap+GDK0wnacPQFpcG1AE9RMq3aeErY5tujekBS32jfC/7AnH7I0v1v1TbbK3Gp XNeiN4QroO+5qaSr0ID2sz5jtBLRb15RMre27E1ImpaIv2Jw8NJgW0k/D1RyKCwaTsgRdwuK Kx/Y91XuSBdz0uOyU/S8kM1+ag0wvsGlpBVxRR/xw/E8M7TEwuCZQArqqTCmkG6HGcXFT0V9 PXFNNgV5jXMQRwU0O/ztJIQqsE5LsUomE//bLwzj9IVsaQpKDqW6TAPjcdBDPLHvriq7kGjt WhVhdl0qEYB8lkBEU7V2Yb+SYhmhpDrti9Fq1EsmhiHSkxJcGREoMK/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eOCrN+Zzwy/Mrx9EPeu59Y5vSJOx/z6OUImD/GhX7Xvkt3kq Er5KTrJz3++B6SH9pum9PuoE/k+nntJkNMmQpR4MCBaV/J9gIOPGodDKnjdng+mXliF3Ptu6 3oxc2RCyGzTlxyMwuc2U5Q7KtUNTdDe8T0uE+9b8BLMVQDDfJjqY0VVqSUwImzTDLX9S4g/8 kC4HRcclk8hpyhY2jKGluZO0awwTIMgVEzmTyBphDg/Gx7dZU1Xf8HFuE+UZ5UDHDTnwgv7E th6RC9+WrhDNspZ9fJjKWRbveQgUFCpe1sa77LAw+XFrKmBHXp9ZVIe90RMe2tRL06BGiRZr jPrnvUsUUsjRoRNJjKKA/REq+sAnhkNPPZ/NNMjaZ5b8Tovi8C0tmxiCHaQYqj7G2rgnT0kt WNyWQQ== Organization: Red Hat In-Reply-To: <20240325124904.398913-8-alexs@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 25.03.24 13:48, alexs@kernel.org wrote: > From: "Alex Shi (tencent)" > > Compound page is checked and skipped before write_protect_page() called, > use folio to save a few compound_head checking. > > Signed-off-by: Alex Shi (tencent) > Cc: Izik Eidus > Cc: Matthew Wilcox > Cc: Andrea Arcangeli > Cc: Hugh Dickins > Cc: Chris Wright > --- > mm/ksm.c | 22 +++++++++++----------- > 1 file changed, 11 insertions(+), 11 deletions(-) > > diff --git a/mm/ksm.c b/mm/ksm.c > index 95a487a21eed..5d1f62e7462a 100644 > --- a/mm/ksm.c > +++ b/mm/ksm.c > @@ -1289,22 +1289,22 @@ static u32 calc_checksum(struct page *page) > return checksum; > } > > -static int write_protect_page(struct vm_area_struct *vma, struct page *page, > +static int write_protect_page(struct vm_area_struct *vma, struct folio *folio, > pte_t *orig_pte) > { > struct mm_struct *mm = vma->vm_mm; > - DEFINE_PAGE_VMA_WALK(pvmw, page, vma, 0, 0); > + DEFINE_FOLIO_VMA_WALK(pvmw, folio, vma, 0, 0); > int swapped; > int err = -EFAULT; > struct mmu_notifier_range range; > bool anon_exclusive; > pte_t entry; > > - pvmw.address = page_address_in_vma(page, vma); > + pvmw.address = page_address_in_vma(&folio->page, vma); > if (pvmw.address == -EFAULT) > goto out; > > - BUG_ON(PageTransCompound(page)); > + VM_BUG_ON(folio_test_large(folio)); I suggest if (WARN_ON_ONCE(folio_test_large(folio))) return err; before the page_address_in_vma() call. Reviewed-by: David Hildenbrand -- Cheers, David / dhildenb