Received: by 2002:a05:6500:2018:b0:1fb:9675:f89d with SMTP id t24csp431998lqh; Fri, 31 May 2024 06:04:57 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXnxaISJ9R227y5r8sNjs8/A6lwOOBuvD/J7gL1X7sF5tAHDTasB53n/2Z4uhMenoV8VslRztRYV6iXzGGp2mo9DKuRznl1nwj8mLPk+w== X-Google-Smtp-Source: AGHT+IG56kRGQN/nU6sXzjqucBSDYcVxtf2FI4A7oRVrHbfsE7s/jyyoH79IQUxjaecWjkvTupi5 X-Received: by 2002:a17:906:b78f:b0:a59:c23d:85d8 with SMTP id a640c23a62f3a-a6822049691mr110124566b.51.1717160697570; Fri, 31 May 2024 06:04:57 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717160697; cv=pass; d=google.com; s=arc-20160816; b=vwTypF2hT7DfJdRDXG2hZ0JIiroswBg9CLHnM3Fhljs4I+dhko/jJO+uZ9gGBxv9Sg zejMlopORzlFZ6P+JGPxwSruls+/uXcIZL8kiy1o5Bf+l1lZ1ZPhfDvhFgq/TCZL8dPN 6XnNdzJe62cR/srSCJRKCp0Rne+Bl5ee3PkV+PsAx4VCx5gcVdLjxubFOUSMb4hx9At8 GnocQIoFcLTWZlATOAFBMVF8ejx5UrI8cVHx4lkicm7N0Rbh9aE5EnBb818TpOXqhJBf 0oWNIgfrVgYaUoEq+SoiO3kOOt5RKjFxk1ny8F12msCXlJVj3moGABXY3z+B0GqAkRch +URg== 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=31tAMzYWbLSmIpJDc+a9K6kwIp/gyego2JxLxPGlZ3g=; fh=73BRTcxq1R08KT3ADOxO25DXbDuFPiLSk9wtD/rl4ow=; b=UpNCvkxbfBGjY0/TL1QyJHlQorYBfXMZLla+jOm/7IOfHq1HwOXFIkGqi9GMm6cla3 hMS7Vkgquc24QgKZstM/JITlhraGLxR1D1PvElc47EjUw0+4+VY8O4qPfnl51KYydAba DF1ZFAco3m+YtM4bfVFJz72auEhh7xEMgBQ+BwZuZuFv2TlIxIzwa/QRYnhVwRo+eHM9 f3s2KObzsTGMOk0jfUyIbEzVGCBIIZP88+Oso9kYrkl0A1QpqevEo8riuDTj3HlbTgaX tyaOJ9xL/hmcOfkDSuVTG1T1kg21EMML3I6rq6g1GJP+gLgUkk/3svQEfLAezWs/vCPX 36RA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=MA9yA1vH; 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-196833-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-196833-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.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 a640c23a62f3a-a67ea38cd95si93963566b.299.2024.05.31.06.04.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 May 2024 06:04:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-196833-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=@redhat.com header.s=mimecast20190719 header.b=MA9yA1vH; 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-196833-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-196833-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 2291C1F24B54 for ; Fri, 31 May 2024 13:04:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B434E158874; Fri, 31 May 2024 13:04:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="MA9yA1vH" 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 1BF7C1586F6 for ; Fri, 31 May 2024 13:04:35 +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=1717160677; cv=none; b=oVir+sbUaigW0gp77ViPth8RPciZY+YQXvcmgkKkTNqmJQDjGLWgQDEBRP/YDTitK91rkcUZqyMlas81AlqGU3RMmbsB0x0qQkdwtp4xMHASJAEUWanBqGr5HURNZatYAhaXRLI7m0GgDJqDA9bwLhZcYZRob//uoq6GPfQvoXU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717160677; c=relaxed/simple; bh=39cWfu7iONUhwloM6DxnKDqOVZkPB+y6Ou1kBTZ3Ghc=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=dRx5lbym/JrHFBodkiOoMjmyMvVsgW2foLys3aezA3qW9gMV/9yFXxlfurjz10tvHgKaJaT+lH7+wC8fI4EJAKJ1GdCH6r3DXyk2AG4L8+COnQR7gnYL2aYDJ1J8pCvFMsd1FmGevWv1hifeJtOVuFz+8MmqpltHPhPcvTS0dG0= 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=MA9yA1vH; 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=1717160675; 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=31tAMzYWbLSmIpJDc+a9K6kwIp/gyego2JxLxPGlZ3g=; b=MA9yA1vHYbg9bpzaRrfGzP9SLsaaos8IYoheV35Y078CI0UfMY9X2tn0rTVwMOlBQC9am1 V2+YpYrolBia6THLnW4zmdrl/NmHGl+C7W9OqncePesgnros7qCTqlrXQ3a57X7pYLvxHY aQIKzEw3vj6z92TQJ2EoVW92PUjZ7p0= Received: from mail-lj1-f198.google.com (mail-lj1-f198.google.com [209.85.208.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-650-xcGjQchVPiWctyKrlofldA-1; Fri, 31 May 2024 09:04:32 -0400 X-MC-Unique: xcGjQchVPiWctyKrlofldA-1 Received: by mail-lj1-f198.google.com with SMTP id 38308e7fff4ca-2ea402284c1so7904551fa.3 for ; Fri, 31 May 2024 06:04:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717160671; x=1717765471; 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=31tAMzYWbLSmIpJDc+a9K6kwIp/gyego2JxLxPGlZ3g=; b=dPDM7LZAWDqV/DXBYd9Ig0GL2+attwG3MNQ7p9usjB2LRbDfqlv7t8LmFXdUVe55EQ xzixmGTtUC3HeFRbGUUvsJxr0uOq1+NeO6qXJjk/0fTTcKlZEqznEDiI8qnjNto67uMj wiEgxunGZIesh51GnhsJMY9q2ywJ2bC6cvFSCqKQGWm/fBn0arE1jvFG5OPWpZawBQd0 FarF6cnM0XMKfO15MSx0tllpl01a/KhYS1flLppdGO2E3ILYiPNDqGrcs5imfAdXWq3p vg/h7p3PWELHBAbyBeZVvp6TzDgfBnWg6+jyY2dBnZspsoxIdTvgQZJJIfLFUsTnSuCk I12Q== X-Forwarded-Encrypted: i=1; AJvYcCUHUHjVYit7YhNP+FYFGBULgBpGGUtVVaDFgdq3MwURmckpWOXK1t7OZvO0DQTflIWV07fhyrsKjXBH1FAdKUfBnjgTabgQxHTQAcxi X-Gm-Message-State: AOJu0Yysx30d9lmK/QbamYZG6KDZEMaqnLd5QkfFKPVXtyMYZArIgGPw GzTvoAecZ80hTZwnD27igsnqPdxzhpgqHd2tcMW7DO7IS/tnwqJ8Kwz0ISYPbUdrnVembF+5sVR SyoOXN7p7Zwajnt30144y20ab0fLGPZKAyOT6wXyt/QQIecvmqKsAhUkgQiBiIQ== X-Received: by 2002:a05:651c:1059:b0:2ea:8462:5927 with SMTP id 38308e7fff4ca-2ea950e5aebmr13136121fa.15.1717160671370; Fri, 31 May 2024 06:04:31 -0700 (PDT) X-Received: by 2002:a05:651c:1059:b0:2ea:8462:5927 with SMTP id 38308e7fff4ca-2ea950e5aebmr13135821fa.15.1717160670794; Fri, 31 May 2024 06:04:30 -0700 (PDT) Received: from ?IPV6:2003:cb:c717:a000:d4df:4b8f:37d4:59e4? (p200300cbc717a000d4df4b8f37d459e4.dip0.t-ipconnect.de. [2003:cb:c717:a000:d4df:4b8f:37d4:59e4]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-421270ad598sm54990385e9.41.2024.05.31.06.04.29 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 31 May 2024 06:04:30 -0700 (PDT) Message-ID: Date: Fri, 31 May 2024 15:04:29 +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 v2] mm/hugetlb: mm/memory_hotplug: use a folio in scan_movable_pages() To: Sidhartha Kumar , linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: akpm@linux-foundation.org, vishal.moola@oracle.com, muchun.song@linux.dev, osalvador@suse.de, willy@infradead.org References: <20240530171427.242018-1-sidhartha.kumar@oracle.com> 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 WhVhdl0qEYB8l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b+MZJk+mZuPxKNVfEQMQ a5SxUEADIPQTPNvBewdeI80yeOCrN+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: <20240530171427.242018-1-sidhartha.kumar@oracle.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 30.05.24 19:14, Sidhartha Kumar wrote: > By using a folio in scan_movable_pages() we convert the last user of the > page-based hugetlb information macro functions to the folio version. > After this conversion, we can safely remove the page-based definitions > from include/linux/hugetlb.h. > > Signed-off-by: Sidhartha Kumar > --- > > v1 -> v2: > simplify pfn skipping logic with pfn |= folio_nr_pages(folio) - 1 > per Matthew > > include/linux/hugetlb.h | 6 +----- > mm/memory_hotplug.c | 11 +++++------ > 2 files changed, 6 insertions(+), 11 deletions(-) > > diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h > index 15a58f69782c..279aca379b95 100644 > --- a/include/linux/hugetlb.h > +++ b/include/linux/hugetlb.h > @@ -616,9 +616,7 @@ static __always_inline \ > bool folio_test_hugetlb_##flname(struct folio *folio) \ > { void *private = &folio->private; \ > return test_bit(HPG_##flname, private); \ > - } \ > -static inline int HPage##uname(struct page *page) \ > - { return test_bit(HPG_##flname, &(page->private)); } > + } > > #define SETHPAGEFLAG(uname, flname) \ > static __always_inline \ > @@ -637,8 +635,6 @@ void folio_clear_hugetlb_##flname(struct folio *folio) \ > #define TESTHPAGEFLAG(uname, flname) \ > static inline bool \ > folio_test_hugetlb_##flname(struct folio *folio) \ > - { return 0; } \ > -static inline int HPage##uname(struct page *page) \ > { return 0; } > > #define SETHPAGEFLAG(uname, flname) \ > diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c > index 431b1f6753c0..9c36eb3bbd3b 100644 > --- a/mm/memory_hotplug.c > +++ b/mm/memory_hotplug.c > @@ -1731,8 +1731,8 @@ static int scan_movable_pages(unsigned long start, unsigned long end, > unsigned long pfn; > > for (pfn = start; pfn < end; pfn++) { > - struct page *page, *head; > - unsigned long skip; > + struct page *page; > + struct folio *folio; > > if (!pfn_valid(pfn)) > continue; > @@ -1753,7 +1753,7 @@ static int scan_movable_pages(unsigned long start, unsigned long end, > > if (!PageHuge(page)) > continue; > - head = compound_head(page); > + folio = page_folio(page); > /* > * This test is racy as we hold no reference or lock. The > * hugetlb page could have been free'ed and head is no longer > @@ -1761,10 +1761,9 @@ static int scan_movable_pages(unsigned long start, unsigned long end, > * cases false positives and negatives are possible. Calling > * code must deal with these scenarios. > */ > - if (HPageMigratable(head)) > + if (folio_test_hugetlb_migratable(folio)) > goto found; > - skip = compound_nr(head) - (pfn - page_to_pfn(head)); > - pfn += skip - 1; > + pfn |= folio_nr_pages(folio) - 1; Likely not exactly what we want? pfn |= folio_nr_pages(folio); Would make sure that we are "one PFN before the start of the next folio". The pfn++ before the next loop iteration would move us to the next folio. Or am I missing something? It might be cleaner if we would handle the "pfn++;" on the "continue;" paths inmstead, and simply here do something like pfn = ALIGN(pfn + 1, folio_nr_pages(folio)); instead. -- Cheers, David / dhildenb