public inbox for linux-m68k@lists.linux-m68k.org
 help / color / mirror / Atom feed
From: Finn Thain <fthain@linux-m68k.org>
To: Michael Schmitz <schmitzmic@gmail.com>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>,
	linux-m68k@lists.linux-m68k.org
Subject: Re: [PATCH RFC] m68k: skip kernel premption if interrupts were disabled
Date: Tue, 26 Mar 2024 20:58:02 +1100 (AEDT)	[thread overview]
Message-ID: <c8a063a1-c72c-9aed-65fc-b2d87f8c7a9b@linux-m68k.org> (raw)
In-Reply-To: <597ab0b3-ac1d-443c-95f7-4f1bbcccae1f@gmail.com>


On Tue, 26 Mar 2024, Michael Schmitz wrote:

> see below (hopefully not whitespace-damaged).
> 

Following your approach, I added mutual exclusion to the other candidate 
in the same file, namely get_pointer_table(). Together with your patch, 
that seems to be sufficient to make stress-ng happy. I don't know the real 
extent of the data race here so I've probably used too much locking in 
this experiment (?)

diff --git a/arch/m68k/mm/motorola.c b/arch/m68k/mm/motorola.c
index 068ad7c9bb5c..d1ad55ee1b60 100644
--- a/arch/m68k/mm/motorola.c
+++ b/arch/m68k/mm/motorola.c
@@ -140,10 +140,14 @@ void __init init_pointer_table(void *table, int type)
 
 void *get_pointer_table(int type)
 {
-	ptable_desc *dp = ptable_list[type].next;
-	unsigned int mask = list_empty(&ptable_list[type]) ? 0 : PD_MARKBITS(dp);
+	ptable_desc *dp;
+	unsigned int mask;
 	unsigned int tmp, off;
 
+	preempt_disable();
+
+	dp = ptable_list[type].next;
+	mask = list_empty(&ptable_list[type]) ? 0 : PD_MARKBITS(dp);
 	/*
 	 * For a pointer table for a user process address space, a
 	 * table is taken from a page allocated for the purpose.  Each
@@ -154,8 +158,13 @@ void *get_pointer_table(int type)
 		void *page;
 		ptable_desc *new;
 
-		if (!(page = (void *)get_zeroed_page(GFP_KERNEL)))
+		sched_preempt_enable_no_resched();
+
+		if (!(page = (void *)get_zeroed_page(GFP_KERNEL))) {
 			return NULL;
+		}
+
+		preempt_disable();
 
 		if (type == TABLE_PTE) {
 			/*
@@ -171,6 +180,7 @@ void *get_pointer_table(int type)
 		PD_MARKBITS(new) = ptable_mask(type) - 1;
 		list_add_tail(new, dp);
 
+		sched_preempt_enable_no_resched();
 		return (pmd_t *)page;
 	}
 
@@ -181,6 +191,7 @@ void *get_pointer_table(int type)
 		/* move to end of list */
 		list_move_tail(dp, &ptable_list[type]);
 	}
+	sched_preempt_enable_no_resched();
 	return page_address(PD_PAGE(dp)) + off;
 }
 

  parent reply	other threads:[~2024-03-26  9:56 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
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 [this message]
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=c8a063a1-c72c-9aed-65fc-b2d87f8c7a9b@linux-m68k.org \
    --to=fthain@linux-m68k.org \
    --cc=geert@linux-m68k.org \
    --cc=linux-m68k@lists.linux-m68k.org \
    --cc=schmitzmic@gmail.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