Linux block layer
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Usama Arif <usama.arif@linux.dev>
Cc: axboe@kernel.dk, linux-block@vger.kernel.org, bsegall@google.com,
	dietmar.eggemann@arm.com, juri.lelli@redhat.com,
	kprateek.nayak@amd.com, linux-kernel@vger.kernel.org,
	mgorman@suse.de, mingo@redhat.com, rostedt@goodmis.org,
	vincent.guittot@linaro.org, vschneid@redhat.com,
	shakeel.butt@linux.dev, hannes@cmpxchg.org, riel@surriel.com,
	kernel-team@meta.com, stable@vger.kernel.org
Subject: Re: [PATCH v2] block: invalidate cached plug timestamp after task switch
Date: Fri, 12 Jun 2026 17:40:22 +0200	[thread overview]
Message-ID: <20260612154022.GC42921@noisy.programming.kicks-ass.net> (raw)
In-Reply-To: <789fd34a-d051-4f98-bd66-e3d99ec2dbb1@linux.dev>

On Fri, Jun 12, 2026 at 11:02:58AM +0100, Usama Arif wrote:
> 
> 
> On 12/06/2026 10:45, Peter Zijlstra wrote:
> > On Fri, Jun 12, 2026 at 02:40:42AM -0700, Usama Arif wrote:
> > 
> >> +static __always_inline void blk_plug_invalidate_ts(void)
> >>  {
> >> +	if (unlikely(current->flags & PF_BLOCK_TS)) {
> >> +		struct blk_plug *plug = current->plug;
> >>  
> >> +		if (plug)
> >> +			plug->cur_ktime = 0;
> >> +		current->flags &= ~PF_BLOCK_TS;
> >> +	}
> >>  }
> > 
> > If you can guarantee PF_BLOCK_TS is only ever set when current->plug,
> > this can be reduced further.
> 
> Thanks for the reviews!
> 
> The invariant holds at set time (the only set in blk_time_get_ns() is
> gated by if (!plug)) and through the only legitimate plug clear in
> blk_finish_plug() (which goes through __blk_flush_plug() that clears
> PF_BLOCK_TS first).
> 
> However, copy_process() sets p->plug = NULL for the child but doesn't
> strip PF_BLOCK_TS from the inherited flags.
> 
> I think the if(plug) is a good defensive check, but can also do the below
> if you prefer?

I think that's worth the extra few lines.

  reply	other threads:[~2026-06-12 15:40 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-12  9:40 [PATCH v2] block: invalidate cached plug timestamp after task switch Usama Arif
2026-06-12  9:45 ` Peter Zijlstra
2026-06-12 10:02   ` Usama Arif
2026-06-12 15:40     ` Peter Zijlstra [this message]
2026-06-12 15:47       ` Usama Arif

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=20260612154022.GC42921@noisy.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=axboe@kernel.dk \
    --cc=bsegall@google.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=hannes@cmpxchg.org \
    --cc=juri.lelli@redhat.com \
    --cc=kernel-team@meta.com \
    --cc=kprateek.nayak@amd.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mgorman@suse.de \
    --cc=mingo@redhat.com \
    --cc=riel@surriel.com \
    --cc=rostedt@goodmis.org \
    --cc=shakeel.butt@linux.dev \
    --cc=stable@vger.kernel.org \
    --cc=usama.arif@linux.dev \
    --cc=vincent.guittot@linaro.org \
    --cc=vschneid@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