From: Ira Weiny <ira.weiny@intel.com>
To: Chaitanya Kulkarni <Chaitanya.Kulkarni@wdc.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
David Sterba <dsterba@suse.cz>,
"hch@infradead.org" <hch@infradead.org>,
Matthew Wilcox <willy@infradead.org>, "clm@fb.com" <clm@fb.com>,
"josef@toxicpanda.com" <josef@toxicpanda.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-fsdevel@vger.kernel.org" <linux-fsdevel@vger.kernel.org>
Subject: Re: [PATCH V2 4/8] mm/highmem: Add VM_BUG_ON() to mem*_page() calls
Date: Wed, 10 Feb 2021 08:31:01 -0800 [thread overview]
Message-ID: <20210210163101.GC3014244@iweiny-DESK2.sc.intel.com> (raw)
In-Reply-To: <BYAPR04MB4965E51F07F1AB084BC1FA84868D9@BYAPR04MB4965.namprd04.prod.outlook.com>
On Wed, Feb 10, 2021 at 06:57:30AM +0000, Chaitanya Kulkarni wrote:
> On 2/9/21 22:25, ira.weiny@intel.com wrote:
> > From: Ira Weiny <ira.weiny@intel.com>
> >
> > Add VM_BUG_ON bounds checks to ensure the newly lifted and created page
> > memory operations do not result in corrupted data in neighbor pages and
> > to make them consistent with zero_user().[1][2]
> >
> I did not understand this, in my tree :-
>
> zero_user()
> -> zero_user_segments()
>
> which uses BUG_ON(), the commit log says add VM_BUG_ON(), isn't that
> inconsistent withwhat is there in zero_user_segments() which uses BUG_ON() ?
>
> Also, this patch uses BUG_ON() which doesn't match the commit log that says
> ADD VM_BUG_ON(),
Oops, yea that 'consistent with zero_user()' was carried over from the BUG_ON
commit comment in the original patch...
The comment should be deleted.
But I'm going to wait because Christoph prefers BUG_ON...
Ira
>
> Did I interpret the commit log wrong ?
>
> [1]
> void zero_user_segments(struct page *page, unsigned start1, unsigned end1,
> 365 unsigned start2, unsigned end2)
> 366 {
> 367 unsigned int
> i;
>
> 368
> 369 BUG_ON(end1 > page_size(page) || end2 > page_size(page));
> 370
> 371 for (i = 0; i < compound_nr(page); i++) {
> 372 void *kaddr = NULL;
> 373
> 374 if (start1 < PAGE_SIZE || start2 < PAGE_SIZE)
> 375 kaddr = kmap_atomic(page + i);
> 376
> 377 if (start1 >= PAGE_SIZE) {
> 378 start1 -= PAGE_SIZE;
> 379 end1 -= PAGE_SIZE;
> 380 } else {
> 381 unsigned this_end = min_t(unsigned, end1,
> PAGE_SIZE);
> 382
> 383 if (end1 > start1)
> 384 memset(kaddr + start1, 0, this_end -
> start1);
> 385 end1 -= this_end;
> 386 start1 = 0;
> 387 }
> 388
> 389 if (start2 >= PAGE_SIZE) {
> 390 start2 -= PAGE_SIZE;
> 391 end2 -= PAGE_SIZE;
> 392 } else {
> 393 unsigned this_end = min_t(unsigned, end2,
> PAGE_SIZE);
> 394
> 395 if (end2 > start2)
> 396 memset(kaddr + start2, 0, this_end -
> start2);
> 397 end2 -= this_end;
> 398 start2 = 0;
> 399 }
> 400
> 401 if (kaddr) {
> 402 kunmap_atomic(kaddr);
> 403 flush_dcache_page(page + i);
> 404 }
> 405
> 406 if (!end1 && !end2)
> 407 break;
> 408 }
> 409
> 410 BUG_ON((start1 | start2 | end1 | end2) != 0);
> 411 }
> 412 EXPORT_SYMBOL(zero_user_segments);
>
>
>
next prev parent reply other threads:[~2021-02-10 16:37 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-10 6:22 [PATCH V2 0/8] btrfs: convert kmaps to core page calls ira.weiny
2021-02-10 6:22 ` [PATCH V2 1/8] mm/highmem: Lift memcpy_[to|from]_page to core ira.weiny
2021-02-10 6:33 ` Chaitanya Kulkarni
2021-02-10 12:53 ` Christoph Hellwig
2021-02-10 6:22 ` [PATCH V2 2/8] mm/highmem: Convert memcpy_[to|from]_page() to kmap_local_page() ira.weiny
2021-02-10 6:37 ` Chaitanya Kulkarni
2021-02-10 12:54 ` Christoph Hellwig
2021-02-10 6:22 ` [PATCH V2 3/8] mm/highmem: Introduce memcpy_page(), memmove_page(), and memset_page() ira.weiny
2021-02-10 6:46 ` Chaitanya Kulkarni
2021-02-10 12:54 ` Christoph Hellwig
2021-02-10 6:22 ` [PATCH V2 4/8] mm/highmem: Add VM_BUG_ON() to mem*_page() calls ira.weiny
2021-02-10 6:57 ` Chaitanya Kulkarni
2021-02-10 16:31 ` Ira Weiny [this message]
2021-02-10 12:55 ` Christoph Hellwig
2021-02-10 16:29 ` Ira Weiny
2021-02-10 16:41 ` Christoph Hellwig
2021-02-10 17:04 ` Ira Weiny
2021-02-10 18:56 ` Matthew Wilcox
2021-02-10 21:22 ` Ira Weiny
2021-02-11 18:52 ` David Sterba
2021-02-10 17:49 ` [PATCH V2.1] " ira.weiny
2021-02-10 6:22 ` [PATCH V2 5/8] iov_iter: Remove memzero_page() in favor of zero_user() ira.weiny
2021-02-10 12:55 ` Christoph Hellwig
2021-02-10 6:22 ` [PATCH V2 6/8] btrfs: use memcpy_[to|from]_page() and kmap_local_page() ira.weiny
2021-02-10 12:56 ` Christoph Hellwig
2021-02-10 6:22 ` [PATCH V2 7/8] btrfs: use copy_highpage() instead of 2 kmaps() ira.weiny
2021-02-10 12:56 ` Christoph Hellwig
2021-02-10 6:22 ` [PATCH V2 8/8] btrfs: convert to zero_user() ira.weiny
2021-02-10 12:57 ` Christoph Hellwig
2021-02-11 19:38 ` [PATCH V2 0/8] btrfs: convert kmaps to core page calls David Sterba
2021-02-11 21:32 ` Ira Weiny
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=20210210163101.GC3014244@iweiny-DESK2.sc.intel.com \
--to=ira.weiny@intel.com \
--cc=Chaitanya.Kulkarni@wdc.com \
--cc=akpm@linux-foundation.org \
--cc=clm@fb.com \
--cc=dsterba@suse.cz \
--cc=hch@infradead.org \
--cc=josef@toxicpanda.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--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;
as well as URLs for NNTP newsgroup(s).