Re: [PATCH v2 3/8] drm/i915: Don't check for atomic context on PREEMPT_RT

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 14/06/2024 12:05, Sebastian Andrzej Siewior wrote:
On 2024-06-14 09:32:07 [+0100], Tvrtko Ursulin wrote:
I think this could be okay-ish in principle, but the commit text is not
entirely accurate because there is no direct coupling between the wait
helpers and the uncore lock. They can be used from any atomic context.

Okay-ish in principle because there is sufficient testing in Intel's CI on
non-PREEMPT_RT kernels to catch any conceptual misuses.

You just avoid disabling preemption if you expect to be in atomic
context to save a few cycles. It wouldn't hurt to disable it anyway. The
only reason you need it is to remain on the same CPU while reading the
clock because it is not guaranteed otherwise.

Ah no, that is not why. Reason for conditional disabling of preemption is to have an implementation for very short delays which does not run with preemption permanently disabled. So it is disabled only around time tracking.

Delays > 50ms are detected at build time.

Right, point of that is to ask the contributor if they are sure this is what they want. Catching misuse of the short delay wait helper step one..

But see also the caller in skl_pcode_request. It is a bit harder to hit
since it is the fallback path. Or gen5_rps_enable which nests under a
different lock.

Hmm would there be a different helper, or combination of helpers, which
could replace in_atomic() which would do the right thing on both kernels?
Something to tell us we are neither under a spin_lock, nor preempt_disable,
nor interrupts disabled, nor bottom-half. On either stock or PREEMPT_RT.

There is nothing that you can use to deduct that you are under a
spin-lock. preemptible() works only if you have a preemption counter
which is not mandatory. It can affect RCU but not in all configurations.

WARN_ON_ONCE((ATOMIC) && !(!preemptible() || in_hardirq() ||
in_serving_softirq())

Would this work?

Nope. None of this triggers if you acquire a spinlock_t. And I can't
think of something that would always be true.

Bummer.

So the question is why do you need to know if the context is atomic?
The only impact is avoiding disabling preemption. Is it that important
to avoid it?
If so would cant_migrate() work? It requires CONFIG_DEBUG_ATOMIC_SLEEP=y
to do the trick.

... catching misuse of atomic wait helpers step 2 - are you calling it from a non-atomic context without the real need. So should use the non-atomic helper instead.

When i915 development was very active and with a lot of contributors it was beneficial to catch these things which code review would easily miss.

Now that the pace is much, much slower, it is probably not very important. So this patch is acceptable for what I am concerned and:

Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@xxxxxxxxxx>

Actually please also add the PREEMPT_RT angle to the comment above _WAIT_FOR_ATOMIC_CHECK. Sometimes lines change and git blame makes it hard to find the commit text.

Regards,

Tvrtko


Regards,

Tvrtko

Sebastian



[Index of Archives]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux