From: Jan Kara <jack@suse.cz>
To: Harshad Shirwadkar <harshadshirwadkar@gmail.com>
Cc: linux-ext4@vger.kernel.org, tytso@mit.edu, saukad@google.com,
harshads@google.com
Subject: Re: [PATCH v6 09/10] ext4: temporarily elevate commit thread priority
Date: Fri, 28 Jun 2024 16:42:30 +0200 [thread overview]
Message-ID: <20240628144230.cknr266ckzyjmtry@quack3> (raw)
In-Reply-To: <20240529012003.4006535-10-harshadshirwadkar@gmail.com>
On Wed 29-05-24 01:20:02, Harshad Shirwadkar wrote:
> Unlike JBD2 based full commits, there is no dedicated journal thread
> for fast commits. Thus to reduce scheduling delays between IO
> submission and completion, temporarily elevate the committer thread's
> priority to match the configured priority of the JBD2 journal
> thread.
>
> Signed-off-by: Harshad Shirwadkar <harshadshirwadkar@gmail.com>
This makes some sense although I'd note that io priority is getting less
and less use these days since IO is now mostly controlled through cgroup
controllers and they don't give a damn about IO priority. E.g. blk-iocost
controller uses bio_issue_as_root_blkg() (which boils down to bio->bi_opf &
(REQ_META | REQ_SWAP)) to determine whether it should avoid throttling IOs
to avoid priority inversion (exactly the case of fast-commit). So I think
properly annotating journal IO with REQ_META will bring much more tangible
benefit in common configurations that bother to control IO and then this
needn't be even needed. But I'm not really opposed either so feel free to
add:
Reviewed-by: Jan Kara <jack@suse.cz>
Honza
> ---
> fs/ext4/ext4.h | 4 +++-
> fs/ext4/fast_commit.c | 13 +++++++++++++
> fs/ext4/super.c | 5 ++---
> 3 files changed, 18 insertions(+), 4 deletions(-)
>
> diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
> index 3721daea2890..d52df8a85271 100644
> --- a/fs/ext4/ext4.h
> +++ b/fs/ext4/ext4.h
> @@ -2287,10 +2287,12 @@ static inline int ext4_forced_shutdown(struct super_block *sb)
> #define EXT4_DEFM_NODELALLOC 0x0800
>
> /*
> - * Default journal batch times
> + * Default journal batch times and ioprio.
> */
> #define EXT4_DEF_MIN_BATCH_TIME 0
> #define EXT4_DEF_MAX_BATCH_TIME 15000 /* 15ms */
> +#define EXT4_DEF_JOURNAL_IOPRIO (IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE, 3))
> +
>
> /*
> * Minimum number of groups in a flexgroup before we separate out
> diff --git a/fs/ext4/fast_commit.c b/fs/ext4/fast_commit.c
> index 35c89bee452c..55a13d3ff681 100644
> --- a/fs/ext4/fast_commit.c
> +++ b/fs/ext4/fast_commit.c
> @@ -1205,6 +1205,7 @@ int ext4_fc_commit(journal_t *journal, tid_t commit_tid)
> int subtid = atomic_read(&sbi->s_fc_subtid);
> int status = EXT4_FC_STATUS_OK, fc_bufs_before = 0;
> ktime_t start_time, commit_time;
> + int old_ioprio, journal_ioprio;
>
> if (!test_opt2(sb, JOURNAL_FAST_COMMIT))
> return jbd2_complete_transaction(journal, commit_tid);
> @@ -1212,6 +1213,7 @@ int ext4_fc_commit(journal_t *journal, tid_t commit_tid)
> trace_ext4_fc_commit_start(sb, commit_tid);
>
> start_time = ktime_get();
> + old_ioprio = get_current_ioprio();
>
> restart_fc:
> ret = jbd2_fc_begin_commit(journal, commit_tid);
> @@ -1242,6 +1244,15 @@ int ext4_fc_commit(journal_t *journal, tid_t commit_tid)
> goto fallback;
> }
>
> + /*
> + * Now that we know that this thread is going to do a fast commit,
> + * elevate the priority to match that of the journal thread.
> + */
> + if (journal->j_task->io_context)
> + journal_ioprio = sbi->s_journal->j_task->io_context->ioprio;
> + else
> + journal_ioprio = EXT4_DEF_JOURNAL_IOPRIO;
> + set_task_ioprio(current, journal_ioprio);
> fc_bufs_before = (sbi->s_fc_bytes + bsize - 1) / bsize;
> ret = ext4_fc_perform_commit(journal);
> if (ret < 0) {
> @@ -1256,6 +1267,7 @@ int ext4_fc_commit(journal_t *journal, tid_t commit_tid)
> }
> atomic_inc(&sbi->s_fc_subtid);
> ret = jbd2_fc_end_commit(journal);
> + set_task_ioprio(current, old_ioprio);
> /*
> * weight the commit time higher than the average time so we
> * don't react too strongly to vast changes in the commit time
> @@ -1265,6 +1277,7 @@ int ext4_fc_commit(journal_t *journal, tid_t commit_tid)
> return ret;
>
> fallback:
> + set_task_ioprio(current, old_ioprio);
> ret = jbd2_fc_end_commit_fallback(journal);
> ext4_fc_update_stats(sb, status, 0, 0, commit_tid);
> return ret;
> diff --git a/fs/ext4/super.c b/fs/ext4/super.c
> index 77173ec91e49..18d9d2631559 100644
> --- a/fs/ext4/super.c
> +++ b/fs/ext4/super.c
> @@ -1833,7 +1833,6 @@ static const struct fs_parameter_spec ext4_param_specs[] = {
> {}
> };
>
> -#define DEFAULT_JOURNAL_IOPRIO (IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE, 3))
>
> #define MOPT_SET 0x0001
> #define MOPT_CLEAR 0x0002
> @@ -5211,7 +5210,7 @@ static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb)
>
> /* Set defaults for the variables that will be set during parsing */
> if (!(ctx->spec & EXT4_SPEC_JOURNAL_IOPRIO))
> - ctx->journal_ioprio = DEFAULT_JOURNAL_IOPRIO;
> + ctx->journal_ioprio = EXT4_DEF_JOURNAL_IOPRIO;
>
> sbi->s_inode_readahead_blks = EXT4_DEF_INODE_READAHEAD_BLKS;
> sbi->s_sectors_written_start =
> @@ -6471,7 +6470,7 @@ static int __ext4_remount(struct fs_context *fc, struct super_block *sb)
> ctx->journal_ioprio =
> sbi->s_journal->j_task->io_context->ioprio;
> else
> - ctx->journal_ioprio = DEFAULT_JOURNAL_IOPRIO;
> + ctx->journal_ioprio = EXT4_DEF_JOURNAL_IOPRIO;
>
> }
>
> --
> 2.45.1.288.g0e0cd299f1-goog
>
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
next prev parent reply other threads:[~2024-06-28 14:42 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-29 1:19 [PATCH v6 00/10] Ext4 fast commit performance patch series Harshad Shirwadkar
2024-05-29 1:19 ` [PATCH v6 01/10] ext4: convert i_fc_lock to spinlock Harshad Shirwadkar
2024-06-21 16:19 ` Jan Kara
2024-05-29 1:19 ` [PATCH v6 02/10] ext4: for committing inode, make ext4_fc_track_inode wait Harshad Shirwadkar
2024-06-21 16:33 ` Jan Kara
2024-06-28 14:45 ` Jan Kara
2024-07-01 22:08 ` Theodore Ts'o
2024-07-12 17:09 ` harshad shirwadkar
2024-05-29 1:19 ` [PATCH v6 03/10] ext4: mark inode dirty before grabbing i_data_sem in ext4_setattr Harshad Shirwadkar
2024-06-28 13:15 ` Jan Kara
2024-05-29 1:19 ` [PATCH v6 04/10] ext4: rework fast commit commit path Harshad Shirwadkar
2024-06-28 13:43 ` Jan Kara
2024-07-13 1:38 ` harshad shirwadkar
2024-07-17 12:11 ` Jan Kara
2024-05-29 1:19 ` [PATCH v6 05/10] ext4: drop i_fc_updates from inode fc info Harshad Shirwadkar
2024-05-29 1:19 ` [PATCH v6 06/10] ext4: update code documentation Harshad Shirwadkar
2024-05-29 1:20 ` [PATCH v6 07/10] ext4: add nolock mode to ext4_map_blocks() Harshad Shirwadkar
2024-06-28 14:18 ` Jan Kara
2024-07-13 2:01 ` harshad shirwadkar
2024-07-17 13:07 ` Jan Kara
2024-05-29 1:20 ` [PATCH v6 08/10] ext4: introduce selective flushing in fast commit Harshad Shirwadkar
2024-06-28 14:33 ` Jan Kara
2024-05-29 1:20 ` [PATCH v6 09/10] ext4: temporarily elevate commit thread priority Harshad Shirwadkar
2024-06-28 14:42 ` Jan Kara [this message]
2024-05-29 1:20 ` [PATCH v6 10/10] ext4: make fast commit ineligible on ext4_reserve_inode_write failure Harshad Shirwadkar
2024-06-28 14:47 ` Jan Kara
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=20240628144230.cknr266ckzyjmtry@quack3 \
--to=jack@suse.cz \
--cc=harshads@google.com \
--cc=harshadshirwadkar@gmail.com \
--cc=linux-ext4@vger.kernel.org \
--cc=saukad@google.com \
--cc=tytso@mit.edu \
/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