Re: [PATCH][2.5] fix preempt-issues with smp_call_function()

Thomas Schlichter (schlicht@uni-mannheim.de)
Wed, 26 Feb 2003 11:52:45 +0100


--Boundary-02=_DyJX+1xlWmxP1wo
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Content-Description: signed data
Content-Disposition: inline

Dave Jones <davej@codemonkey.org.uk> wrote:
> btw, (unrelated) shouldn't smp_call_function be doing magick checks
> with cpu_online() ?

Andrew Morton wrote:
> Looks OK? It sprays the IPI out to all the other CPUs in cpu_online_map,
> and waits for num_online_cpus()-1 CPUs to answer.
>
> All very racy in the presence of CPUs going offline, but that's all over
> the place. Depends how the offlining will be done I guess.

Well, now I see the check for num_online_cpus() !=3D 1 in smp_call_function=
(),=20
too, so the check in on_each_cpu() is not needed and possibly better this=20
patch should apply to the include/linux/smp.h file...

Thomas

=2D-- linux-2.5.63/include/linux/smp.h.orig Mon Feb 24 20:05:33 2003
+++ linux-2.5.63/include/linux/smp.h Wed Feb 26 11:41:45 2003
@@ -10,9 +10,10 @@

#ifdef CONFIG_SMP

+#include <linux/preempt.h>
#include <linux/kernel.h>
#include <linux/compiler.h>
=2D#include <linux/threads.h>
+#include <linux/thread_info.h>
#include <asm/smp.h>
#include <asm/bug.h>

@@ -54,6 +55,24 @@
int retry, int wait);

/*
+ * Call a function on all processors
+ */
+static inline int on_each_cpu(void (*func) (void *info), void *info,
+ int retry, int wait)
+{
+ int ret;
+
+ preempt_disable();
+
+ ret =3D smp_call_function(func, info, retry, wait);
+ func(info);
+
+ preempt_enable();
+
+ return ret;
+}
+
+/*
* True once the per process idle is forked
*/
extern int smp_threads_ready;
@@ -96,6 +115,7 @@
#define hard_smp_processor_id() 0
#define smp_threads_ready 1
#define smp_call_function(func,info,retry,wait) ({ 0; })
+#define on_each_cpu(func,info,retry,wait) ({ func(info); 0; })
static inline void smp_send_reschedule(int cpu) { }
static inline void smp_send_reschedule_all(void) { }
#define cpu_online_map 1

--Boundary-02=_DyJX+1xlWmxP1wo
Content-Type: application/pgp-signature
Content-Description: signature

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQA+XJyDYAiN+WRIZzQRAvasAJ9q/oCm7lSxL1IsoZs51yb0ag0trACgn/gQ
x17Jq8JVAeK3RDClpXmNlVs=
=8t1Q
-----END PGP SIGNATURE-----

--Boundary-02=_DyJX+1xlWmxP1wo--

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/