linux-m68k.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michael Schmitz <schmitzmic@gmail.com>
To: Finn Thain <fthain@linux-m68k.org>,
	Geert Uytterhoeven <geert@linux-m68k.org>
Cc: linux-m68k@lists.linux-m68k.org
Subject: Re: [PATCH RFC] m68k: skip kernel premption if interrupts were disabled
Date: Sat, 23 Mar 2024 19:32:12 +1300	[thread overview]
Message-ID: <5e344842-0b19-1f83-dc77-51210a8880c7@gmail.com> (raw)
In-Reply-To: <40928e38-0de7-75a6-d5f7-8c913155da03@linux-m68k.org>

Hi Finn,

Am 23.03.2024 um 17:35 schrieb Finn Thain:
> On Fri, 22 Mar 2024, Michael Schmitz wrote:
>
>> Am 22.03.2024 um 17:53 schrieb Michael Schmitz:
>>> Am 22.03.2024 um 17:39 schrieb Finn Thain:
>>>
>>>> I find that patch description to be a bit confusing, since
>>>> preempt_schedule_irq() requires that interrupts were disabled:
>>>>
>>>>         BUG_ON(preempt_count() || !irqs_disabled());
>>>>
>>>> Looking more closely I see that you're testing the IPL bits from the
>>>> stack not the status register...
>>>
>>> Yes - the problem appears to be that if we enter preemption when about
>>> to return to kernel code that had interrupts disabled, bad things may
>>> happen [...]
>>> That's independent from having interrupts disabled in the currently
>>> active exception.
>>>
>
> Is it? If interrupts were disabled by the code we're returning to, surely
> they must be disabled still (in the Status reg, for the BUG_ON above).

They would still be disabled, but by calling preempt_schedule_irq() they 
will be reenabled before calling schedule(). At that time, another 
interrupt may come in, and change things from under the piece of code 
that had interrupts disabled.

That won't happen without preemption.

What's more, I suspect schedule() may cause another process to exit that 
would otherwise first take a signal, and signal delivery then repeats 
the vma teardown on process exit. At least that is how I read those 
'table already freed' stack traces.

>
>>>>
>>>> It's not clear to me which pre-emption opportunities remain in
>>>> effect. E.g. is full preemption (in effect) the same as voluntary
>>>> preemption?
>>>
>>> Good question - I'll have to instrument preempt_schedule_irq() and see
>>> if it gets called at all with my patch.
>>
>> Can't see preempt_schedule_irq() entered with my patch ...
>>
>
> Neither can I: A quick "stress-ng --zombie -1 -t 100" test passed without
> ever calling preempt_schedule_irq() in QEMU.

Right. Whenever I allow preemption with IPL (in the saved frame's SR) > 
0, I eventually get the 'table already free' panic. Trying to save the 
whole frame for later printing in free_pointer_table() hasn't been too 
helpful though. The saved frame's PC does not appear anywhere in the trace.

>
>> In general, full preemption is not the same as voluntary preemption.
>> Full preemption attempts to preempt on every return from interrupt or
>> syscall (given certain constraints are fulfilled such as we're not
>> currently in any interrupt or already preempting, and there's other work
>> that needs scheduling).
>>
>> The constraint that interrupts must not be disabled in the saved stack
>> frame apparently is one constraint too many...
>>
>
> I dropped the mailing list from the recipients in my previous message.
> This might a good time to follow up on the list in case Geert can shed
> some light.

Adding Geert and list back in now ...

Cheers,

	Michael


>

  parent reply	other threads:[~2024-03-23  6:32 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-22  1:48 [PATCH RFC] m68k: skip kernel premption if interrupts were disabled Michael Schmitz
     [not found] ` <fcabda73-4b16-ee2c-e993-2bfcf392a26a@linux-m68k.org>
     [not found]   ` <e89bf618-2fa8-7cbd-16ed-d021a9a7f740@gmail.com>
     [not found]     ` <948c12e4-e85f-a86c-ae95-a1eb03ca026d@gmail.com>
     [not found]       ` <40928e38-0de7-75a6-d5f7-8c913155da03@linux-m68k.org>
2024-03-23  6:32         ` Michael Schmitz [this message]
2024-03-25  6:41           ` Michael Schmitz
2024-03-25 22:28             ` Finn Thain
2024-03-25 22:31               ` Michael Schmitz
2024-03-26  0:41                 ` Finn Thain
2024-03-26  9:58                 ` Finn Thain
2024-03-26 19:59                   ` Michael Schmitz
2024-03-26 22:03                     ` Finn Thain
2024-03-26 22:35                       ` Michael Schmitz
2024-03-27  3:50                         ` Finn Thain
2024-03-27  6:56                           ` Michael Schmitz
2024-03-27 23:29                             ` Spinlock debug, was " Finn Thain
     [not found]                               ` <7aee9fd9-1c0e-4874-bb86-e512a7c0caa6@gmail.com>
2024-03-28  2:48                                 ` Finn Thain
2024-03-28 19:54                                   ` Michael Schmitz
2024-03-30  2:46                                     ` Michael Schmitz
2024-03-30  6:23                                       ` Finn Thain
2024-03-31  6:14                                         ` Michael Schmitz
2024-03-27  8:38                           ` Finn Thain
2024-03-27 22:59                             ` Michael Schmitz
2024-03-27  8:22                     ` Geert Uytterhoeven

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=5e344842-0b19-1f83-dc77-51210a8880c7@gmail.com \
    --to=schmitzmic@gmail.com \
    --cc=fthain@linux-m68k.org \
    --cc=geert@linux-m68k.org \
    --cc=linux-m68k@lists.linux-m68k.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
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).