mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: Matthew Wilcox <willy@infradead.org>,
	"Vishal Moola (Oracle)" <vishal.moola@gmail.com>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	Jordan Rome <linux@jordanrome.com>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [RFC PATCH 1/3] mm/memory.c: convert __copy_remote_vm_str() to folios
Date: Wed, 25 Jun 2025 20:24:14 +0200	[thread overview]
Message-ID: <cba29ce0-24ef-4cef-9e54-74418c55c217@redhat.com> (raw)
In-Reply-To: <aFw5NuCbgJOBmG97@casper.infradead.org>

On 25.06.25 20:00, Matthew Wilcox wrote:
> On Wed, Jun 25, 2025 at 10:48:39AM -0700, Vishal Moola (Oracle) wrote:
>> +++ b/mm/memory.c
>> @@ -6820,9 +6820,10 @@ static int __copy_remote_vm_str(struct mm_struct *mm, unsigned long addr,
>>   	}
>>   
>>   	while (len) {
>> -		int bytes, offset, retval;
>> +		int bytes, folio_offset, page_offset retval;
> 
> offset_in_folio() returns a size_t so that we can support folios larger
> than 2GB (which is a real possibility here; hugetlbfs might end up with
> a 16GB folio on some architectures).
> 
>> @@ -6837,17 +6838,20 @@ static int __copy_remote_vm_str(struct mm_struct *mm, unsigned long addr,
>>   			goto out;
>>   		}
>>   
>> +		folio = page_folio(page);
>>   		bytes = len;
>> -		offset = addr & (PAGE_SIZE - 1);
>> -		if (bytes > PAGE_SIZE - offset)
>> -			bytes = PAGE_SIZE - offset;
>> +		folio_offset = offset_in_folio(folio, addr);
> 
> Umm.  Not sure this is safe.  A folio might be mapped misaligned, so
> 'addr' might not give you the right offset within the folio.  I think
> you might need to use addr - (vma->vm_pgoff << PAGE_SHIFT).  But I'd
> defer to others here ... particularly when it comes to anonymous folios.

Not special to anon memory I think ... :)

Only the offset within a page is okay to derive (existing code).

-- 
Cheers,

David / dhildenb


  reply	other threads:[~2025-06-25 18:24 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-25 17:48 [RFC PATCH 0/3] Some remote_vm folio conversions Vishal Moola (Oracle)
2025-06-25 17:48 ` [RFC PATCH 1/3] mm/memory.c: convert __copy_remote_vm_str() to folios Vishal Moola (Oracle)
2025-06-25 18:00   ` Matthew Wilcox
2025-06-25 18:24     ` David Hildenbrand [this message]
2025-06-25 19:23     ` Vishal Moola (Oracle)
2025-06-26  3:02     ` Matthew Wilcox
2025-06-26  8:14       ` David Hildenbrand
2025-06-25 17:48 ` [RFC PATCH 2/3] mm/memory.c: convert __access_remote_vm() " Vishal Moola (Oracle)
2025-06-25 17:48 ` [RFC PATCH 3/3] mm: Remove unmap_and_put_page() Vishal Moola (Oracle)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cba29ce0-24ef-4cef-9e54-74418c55c217@redhat.com \
    --to=david@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux@jordanrome.com \
    --cc=vishal.moola@gmail.com \
    --cc=willy@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®