dm-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
From: Pankaj Raghav <p.raghav@samsung.com>
To: Mikulas Patocka <mpatocka@redhat.com>
Cc: Jens Axboe <axboe@kernel.dk>,
	Christoph Hellwig <hch@infradead.org>,
	Chaitanya Kulkarni <chaitanyak@nvidia.com>,
	linux-block@vger.kernel.org, Li Nan <linan666@huaweicloud.com>,
	dm-devel@redhat.com, Zdenek Kabelac <zkabelac@redhat.com>,
	p.raghav@samsung.com
Subject: Re: [dm-devel] [PATCH v2 1/3] brd: extend the rcu regions to cover read and write
Date: Thu, 27 Jul 2023 10:31:57 +0200	[thread overview]
Message-ID: <20230727083157.bwtndptv6rvoyezs@localhost> (raw)
In-Reply-To: <7d99fa-9c13-ab2a-acde-1f8bbc63bf3@redhat.com>

> Index: linux-2.6/drivers/block/brd.c
> ===================================================================
> --- linux-2.6.orig/drivers/block/brd.c
> +++ linux-2.6/drivers/block/brd.c
> @@ -150,23 +150,27 @@ static void copy_to_brd(struct brd_devic
>  	size_t copy;
>  
>  	copy = min_t(size_t, n, PAGE_SIZE - offset);
> +	rcu_read_lock();
>  	page = brd_lookup_page(brd, sector);

xa_load() inside brd_lookup_page() also calls rcu read lock. Instead of
nesting rcu locks, could we modify the brd_lookup_page to use:

diff --git a/drivers/block/brd.c b/drivers/block/brd.c
index 970bd6ff38c4..acc37bfdd181 100644
--- a/drivers/block/brd.c
+++ b/drivers/block/brd.c
@@ -55,7 +55,9 @@ static struct page *brd_lookup_page(struct brd_device *brd, sector_t sector)
        struct page *page;
 
        idx = sector >> PAGE_SECTORS_SHIFT; /* sector to page index */
-       page = xa_load(&brd->brd_pages, idx);
+
+       XA_STATE(xas, &brd->brd_pages, idx);
+       page = xas_load(&xas);
 
        BUG_ON(page && page->index != idx);

>  	BUG_ON(!page);
>  
>  	dst = kmap_atomic(page);
>  	memcpy(dst + offset, src, copy);
>  	kunmap_atomic(dst);

--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel


      parent reply	other threads:[~2023-07-27  8:41 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-21 13:49 [dm-devel] [PATCH v2 1/3] brd: extend the rcu regions to cover read and write Mikulas Patocka
     [not found] ` <CGME20230727083159eucas1p1c4b907caac8371200bbd465143ac39fd@eucas1p1.samsung.com>
2023-07-27  8:31   ` Pankaj Raghav [this message]

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=20230727083157.bwtndptv6rvoyezs@localhost \
    --to=p.raghav@samsung.com \
    --cc=axboe@kernel.dk \
    --cc=chaitanyak@nvidia.com \
    --cc=dm-devel@redhat.com \
    --cc=hch@infradead.org \
    --cc=linan666@huaweicloud.com \
    --cc=linux-block@vger.kernel.org \
    --cc=mpatocka@redhat.com \
    --cc=zkabelac@redhat.com \
    /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).