IO-Uring Archive on lore.kernel.org
 help / color / Atom feed
From: Jens Axboe <axboe@kernel.dk>
To: Bijan Mottahedeh <bijan.mottahedeh@oracle.com>,
	Pavel Begunkov <asml.silence@gmail.com>
Cc: io-uring@vger.kernel.org, Minchan Kim <minchan@kernel.org>
Subject: Re: [RFC 1/1] io_uring: preserve work->mm since actual work processing may need it
Date: Fri, 10 Apr 2020 20:17:29 -0600
Message-ID: <46e5b8bf-0f14-caff-f706-91794191e730@kernel.dk> (raw)
In-Reply-To: <e8ca3475-5372-3f99-ff95-c383d3599552@oracle.com>

On 4/10/20 12:09 PM, Bijan Mottahedeh wrote:
> On 4/10/2020 10:51 AM, Pavel Begunkov wrote:
>> On 10/04/2020 19:54, Bijan Mottahedeh wrote:
>>>> As I see, this down_read() from the trace is
>>>> down_read(&current->mm->mmap_sem), where current->mm is set by use_mm()
>>>> just several lines above your change. So, what do you mean by passing? I
>>>> don't see do_madvise() __explicitly__ accepting mm as an argument.
>>> I think the sequence is:
>>>
>>> io_madvise()
>>> -> do_madvise(NULL, req->work.mm, ma->addr, ma->len, ma->advice)
>>>                      ^^^^^^^^^^^^
>>>     -> down_read(&mm->mmap_sem)
>>>
>>> I added an assert in do_madvise() for a NULL mm value and hit it running the test.
>>>
>>>> What tree do you use? Extra patches on top?
>>> I'm using next-20200409 with no patches.
>> I see, it came from 676a179 ("mm: pass task and mm to do_madvise"), which isn't
>> in Jen's tree.
>>
>> I don't think your patch will do, because it changes mm refcounting with extra
>> mmdrop() in io_req_work_drop_env(). That's assuming it worked well before.
>>
>> Better fix then is to make it ```do_madvise(NULL, current->mm, ...)```
>> as it actually was at some point in the mentioned patch (v5).
>>
> Ok. Jens had suggested to use req->work.mm in the patch comments so 
> let's just get him to confirm:
> 
> "I think we want to use req->work.mm here - it'll be the same as
> current->mm at this point, but it makes it clear that we're using a
> grabbed mm."

We should just use current->mm, as that matches at that point anyway
since IORING_OP_MADVISE had needs_mm set.

Minchan, can you please make that change?

-- 
Jens Axboe


  reply index

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-09 22:03 [RFC 0/1] " Bijan Mottahedeh
2020-04-09 22:03 ` [RFC 1/1] " Bijan Mottahedeh
2020-04-10  8:47   ` Pavel Begunkov
2020-04-10 16:54     ` Bijan Mottahedeh
2020-04-10 17:51       ` Pavel Begunkov
2020-04-10 17:57         ` Pavel Begunkov
2020-04-10 19:09         ` Bijan Mottahedeh
2020-04-11  2:17           ` Jens Axboe [this message]
2020-04-16 20:24             ` Minchan Kim
2020-04-16 20:30               ` Jens Axboe

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=46e5b8bf-0f14-caff-f706-91794191e730@kernel.dk \
    --to=axboe@kernel.dk \
    --cc=asml.silence@gmail.com \
    --cc=bijan.mottahedeh@oracle.com \
    --cc=io-uring@vger.kernel.org \
    --cc=minchan@kernel.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

IO-Uring Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/io-uring/0 io-uring/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 io-uring io-uring/ https://lore.kernel.org/io-uring \
		io-uring@vger.kernel.org
	public-inbox-index io-uring

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.io-uring


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git