From: Emanuele Giuseppe Esposito <eesposit@redhat.com>
To: Kevin Wolf <kwolf@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>
Cc: "Fam Zheng" <fam@euphon.net>,
"Eduardo Habkost" <eduardo@habkost.net>,
"Vladimir Sementsov-Ogievskiy" <vsementsov@virtuozzo.com>,
"Daniel P. Berrangé" <berrange@redhat.com>,
qemu-block@nongnu.org, "Juan Quintela" <quintela@redhat.com>,
"Markus Armbruster" <armbru@redhat.com>,
"Daniel Henrique Barboza" <danielhb413@gmail.com>,
"Richard Henderson" <richard.henderson@linaro.org>,
"Philippe Mathieu-Daudé" <f4bug@amsat.org>,
"Eric Blake" <eblake@redhat.com>,
qemu-devel@nongnu.org, "Hanna Reitz" <hreitz@redhat.com>,
qemu-ppc@nongnu.org, "Cédric Le Goater" <clg@kaod.org>,
"Stefan Hajnoczi" <stefanha@redhat.com>,
"Denis V. Lunev" <den@openvz.org>,
"David Gibson" <david@gibson.dropbear.id.au>,
"John Snow" <jsnow@redhat.com>,
"Dr. David Alan Gilbert" <dgilbert@redhat.com>,
"Greg Kurz" <groug@kaod.org>
Subject: Re: [PATCH v6 02/33] include/block/block: split header into I/O and global state API
Date: Tue, 8 Feb 2022 11:50:49 +0100 [thread overview]
Message-ID: <28aca5b9-38cd-409c-e63f-3aa28cd1c0ff@redhat.com> (raw)
In-Reply-To: <YgFOeOocta+pPE/y@redhat.com>
On 07/02/2022 17:53, Kevin Wolf wrote:
> Am 01.02.2022 um 11:30 hat Paolo Bonzini geschrieben:
>> On 2/1/22 10:45, Emanuele Giuseppe Esposito wrote:
>>>> That said, even if they are a different category, I think it makes sense
>>>> to leave them in the same header file as I/O functions, because I/O
>>>> functions are locked out between drained_begin and drained_end.
>>>
>>> Proposed category description:
>>> /*
>>> * "Global OR I/O" API functions. These functions can run without
>>> * the BQL, but only in one specific iothread/main loop.
>>> *
>>> * More specifically, these functions use BDRV_POLL_WHILE(bs), which
>>> * requires the caller to be either in the main thread and hold
>>> * the BlockdriverState (bs) AioContext lock, or directly in the
>>> * home thread that runs the bs AioContext. Calling them from
>>> * another thread in another AioContext would cause deadlocks.
>>> *
>>> * Therefore, these functions are not proper I/O, because they
>>> * can't run in *any* iothreads, but only in a specific one.
>>> */
>>>
>>> Functions that will surely go under this category:
>>>
>>> BDRV_POLL_WHILE
>>> bdrv_parent_drained_begin_single
>>> bdrv_parent_drained_end_single
>>> bdrv_drain_poll
>>> bdrv_drained_begin
>>> bdrv_do_drained_begin_quiesce
>>> bdrv_subtree_drained_begin
>>> bdrv_drained_end
>>> bdrv_drained_end_no_poll
>>> bdrv_subtree_drained_end
>>>
>>> (all generated_co_wrapper)
>>> bdrv_truncate
>>> bdrv_check
>>> bdrv_invalidate_cache
>>> bdrv_flush
>>> bdrv_pdiscard
>>> bdrv_readv_vmstate
>>> bdrv_writev_vmstate
>>>
>>>
>>> What I am not sure:
>>>
>>> * bdrv_drain_all_begin - bdrv_drain_all_end - bdrv_drain_all: these were
>>> classified as GS, because thay are always called from the main loop.
>>> Should they go in this new category?
>>
>> 1) They look at the list of BDS's, and 2) you can't in general be sure that
>> all BDS's are in *your* AioContext if you call them from a specific
>> AioContext.
>>
>> So they should be GS.
>
> I agree, calling drain_all functions can only work from the main thread,
> so they are GS.
>
>>> * how should I interpret "all the callers of BDRV_POLL_WHILE"?
>>> Meaning, if I consider also the callers of the callers, we end up
>>> covering much much more functions. Should I only consider the direct
>>> callers (ie the above)?
>>
>> In general it is safe to make a function GS even if it is potentially "GS or
>> I/O", because that _reduces_ the number of places you can call it from.
>> It's likewise safe to make it I/O-only, but probably it makes less sense.
>
> Basically, we have a hierarchy of categories where you can always call
> functions in other categories with less restrictions, but never the
> opposite direction.
Added in the respective category documentation:
> 1. Common functions
* These functions must never call any function from other categories
* (I/O, "I/O or GS", Global State) except this one, but can be invoked by
* all of them.
> 2. I/O functions
* These functions can only call functions from I/O and common categories,
* but can be invoked by GS, "I/O or GS" and I/O APIs.
> 3. I/O or GS functions
* These functions can call any function from I/O, common and this
* categories, but must be invoked only by other "I/O or GS" and GS APIs.
> 4. GS functions
* These functions can call any function from this and other categories
* (I/O, "I/O or GS", common), but must be invoked only by other GS APIs.
Emanuele
>
> So common functions must never call any of the other categories. Global
> state functions can call functions in any category. And "I/O or GS"
> functions like BDRV_POLL_WHILE() can be called by other "I/O or GS" or
> just GS functions, but if it's ever (directly or indirectly) called by
> an I/O or common function, that would be a bug.
>
> Kevin
>
next prev parent reply other threads:[~2022-02-08 10:54 UTC|newest]
Thread overview: 85+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-21 17:05 [PATCH v6 00/33] block layer: split block APIs in global state and I/O Emanuele Giuseppe Esposito
2022-01-21 17:05 ` [PATCH v6 01/33] main-loop.h: introduce qemu_in_main_thread() Emanuele Giuseppe Esposito
2022-01-27 10:56 ` Kevin Wolf
2022-01-31 11:25 ` Emanuele Giuseppe Esposito
2022-01-31 14:33 ` Kevin Wolf
2022-01-31 15:49 ` Paolo Bonzini
2022-02-01 9:08 ` Emanuele Giuseppe Esposito
2022-02-01 10:41 ` Paolo Bonzini
2022-02-01 11:55 ` Kevin Wolf
2022-02-01 12:10 ` Kevin Wolf
2022-01-21 17:05 ` [PATCH v6 02/33] include/block/block: split header into I/O and global state API Emanuele Giuseppe Esposito
2022-01-27 11:01 ` Kevin Wolf
2022-01-31 13:40 ` Emanuele Giuseppe Esposito
2022-01-31 14:54 ` Kevin Wolf
2022-01-31 15:58 ` Paolo Bonzini
2022-02-01 9:45 ` Emanuele Giuseppe Esposito
2022-02-01 10:30 ` Paolo Bonzini
2022-02-07 16:53 ` Kevin Wolf
2022-02-08 10:50 ` Emanuele Giuseppe Esposito [this message]
2022-01-21 17:05 ` [PATCH v6 03/33] assertions for block " Emanuele Giuseppe Esposito
2022-01-21 17:05 ` [PATCH v6 04/33] block/export/fuse.c: allow writable exports to take RESIZE permission Emanuele Giuseppe Esposito
2022-01-25 16:51 ` Hanna Reitz
2022-01-28 14:44 ` Emanuele Giuseppe Esposito
2022-01-21 17:05 ` [PATCH v6 05/33] include/sysemu/block-backend: split header into I/O and global state (GS) API Emanuele Giuseppe Esposito
2022-02-07 17:04 ` Kevin Wolf
2022-01-21 17:05 ` [PATCH v6 06/33] block/block-backend.c: assertions for block-backend Emanuele Giuseppe Esposito
2022-01-26 9:02 ` Hanna Reitz
2022-01-21 17:05 ` [PATCH v6 07/33] include/block/block_int: split header into I/O and global state API Emanuele Giuseppe Esposito
2022-01-21 17:05 ` [PATCH v6 08/33] assertions for block_int " Emanuele Giuseppe Esposito
2022-01-21 17:05 ` [PATCH v6 09/33] block: introduce assert_bdrv_graph_writable Emanuele Giuseppe Esposito
2022-02-07 17:14 ` Kevin Wolf
2022-01-21 17:05 ` [PATCH v6 10/33] include/block/blockjob_int.h: split header into I/O and GS API Emanuele Giuseppe Esposito
2022-01-21 17:05 ` [PATCH v6 11/33] assertions for blockjob_int.h Emanuele Giuseppe Esposito
2022-01-21 17:05 ` [PATCH v6 12/33] block.c: add assertions to static functions Emanuele Giuseppe Esposito
2022-01-21 17:05 ` [PATCH v6 13/33] include/block/blockjob.h: global state API Emanuele Giuseppe Esposito
2022-02-07 17:26 ` Kevin Wolf
2022-02-08 10:50 ` Emanuele Giuseppe Esposito
2022-01-21 17:05 ` [PATCH v6 14/33] assertions for blockjob.h " Emanuele Giuseppe Esposito
2022-01-21 17:05 ` [PATCH v6 15/33] include/sysemu/blockdev.h: " Emanuele Giuseppe Esposito
2022-01-21 17:05 ` [PATCH v6 16/33] assertions for blockdev.h " Emanuele Giuseppe Esposito
2022-01-21 17:05 ` [PATCH v6 17/33] include/block/snapshot: global state API + assertions Emanuele Giuseppe Esposito
2022-01-21 17:05 ` [PATCH v6 18/33] block/copy-before-write.h: " Emanuele Giuseppe Esposito
2022-01-21 17:05 ` [PATCH v6 19/33] block: introduce bdrv_activate Emanuele Giuseppe Esposito
2022-01-26 11:49 ` Hanna Reitz
2022-01-21 17:05 ` [PATCH v6 20/33] block: rename bdrv_invalidate_cache_all, blk_invalidate_cache and test_sync_op_invalidate_cache Emanuele Giuseppe Esposito
2022-01-24 10:44 ` Juan Quintela
2022-01-27 9:18 ` Emanuele Giuseppe Esposito
2022-01-31 15:59 ` Paolo Bonzini
2022-01-26 11:57 ` Hanna Reitz
2022-01-21 17:05 ` [PATCH v6 21/33] block: move BQL logic of bdrv_co_invalidate_cache in bdrv_activate Emanuele Giuseppe Esposito
2022-01-26 12:20 ` Hanna Reitz
2022-01-27 11:03 ` Kevin Wolf
2022-02-02 17:27 ` Paolo Bonzini
2022-02-02 18:27 ` Kevin Wolf
2022-01-21 17:05 ` [PATCH v6 22/33] block/coroutines: I/O API Emanuele Giuseppe Esposito
2022-02-07 17:36 ` Kevin Wolf
2022-01-21 17:05 ` [PATCH v6 23/33] block_int-common.h: split function pointers in BlockDriver Emanuele Giuseppe Esposito
2022-01-26 12:29 ` Hanna Reitz
2022-01-21 17:05 ` [PATCH v6 24/33] block_int-common.h: assertions in the callers of BlockDriver function pointers Emanuele Giuseppe Esposito
2022-01-21 17:05 ` [PATCH v6 25/33] block_int-common.h: split function pointers in BdrvChildClass Emanuele Giuseppe Esposito
2022-01-26 12:42 ` Hanna Reitz
2022-01-28 15:08 ` Emanuele Giuseppe Esposito
2022-01-21 17:05 ` [PATCH v6 26/33] block_int-common.h: assertions in the callers of BdrvChildClass function pointers Emanuele Giuseppe Esposito
2022-01-26 12:46 ` Hanna Reitz
2022-01-21 17:05 ` [PATCH v6 27/33] block-backend-common.h: split function pointers in BlockDevOps Emanuele Giuseppe Esposito
2022-01-21 17:05 ` [PATCH v6 28/33] job.h: split function pointers in JobDriver Emanuele Giuseppe Esposito
2022-01-21 17:05 ` [PATCH v6 29/33] job.h: assertions in the callers of JobDriver funcion pointers Emanuele Giuseppe Esposito
2022-01-26 14:13 ` Hanna Reitz
2022-01-28 15:19 ` Emanuele Giuseppe Esposito
2022-01-31 8:49 ` Hanna Reitz
2022-01-21 17:05 ` [PATCH v6 30/33] include/block/block_int-common.h: introduce bdrv_amend_pre_run and bdrv_amend_clean Emanuele Giuseppe Esposito
2022-01-26 14:54 ` Hanna Reitz
2022-01-21 17:05 ` [PATCH v6 31/33] include/qemu/job.h: introduce job->pre_run() and use it in amend Emanuele Giuseppe Esposito
2022-01-26 15:57 ` Hanna Reitz
2022-02-07 18:14 ` Kevin Wolf
2022-02-08 11:05 ` Emanuele Giuseppe Esposito
2022-01-21 17:05 ` [PATCH v6 32/33] crypto: delegate permission functions to JobDriver .pre_run Emanuele Giuseppe Esposito
2022-01-24 14:41 ` Paolo Bonzini
2022-01-26 16:10 ` Hanna Reitz
2022-01-28 16:57 ` Emanuele Giuseppe Esposito
2022-01-21 17:05 ` [PATCH v6 33/33] block.c: assertions to the block layer permissions API Emanuele Giuseppe Esposito
2022-02-07 18:30 ` [PATCH v6 00/33] block layer: split block APIs in global state and I/O Kevin Wolf
2022-02-08 11:42 ` Emanuele Giuseppe Esposito
2022-02-08 13:08 ` Kevin Wolf
2022-02-10 16:19 ` Emanuele Giuseppe Esposito
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=28aca5b9-38cd-409c-e63f-3aa28cd1c0ff@redhat.com \
--to=eesposit@redhat.com \
--cc=armbru@redhat.com \
--cc=berrange@redhat.com \
--cc=clg@kaod.org \
--cc=danielhb413@gmail.com \
--cc=david@gibson.dropbear.id.au \
--cc=den@openvz.org \
--cc=dgilbert@redhat.com \
--cc=eblake@redhat.com \
--cc=eduardo@habkost.net \
--cc=f4bug@amsat.org \
--cc=fam@euphon.net \
--cc=groug@kaod.org \
--cc=hreitz@redhat.com \
--cc=jsnow@redhat.com \
--cc=kwolf@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=quintela@redhat.com \
--cc=richard.henderson@linaro.org \
--cc=stefanha@redhat.com \
--cc=vsementsov@virtuozzo.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).