All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rene Herman <rene.herman@keyaccess.nl>
To: Gerd Hoffmann <kraxel@suse.de>
Cc: Linux Kernel <linux-kernel@vger.kernel.org>
Subject: Re: [patch] SMP alternatives: skip with UP kernels.
Date: Thu, 11 May 2006 23:07:27 +0200	[thread overview]
Message-ID: <4463A78F.5030703@keyaccess.nl> (raw)
In-Reply-To: <44632A62.2020505@suse.de>

[-- Attachment #1: Type: text/plain, Size: 1686 bytes --]

Gerd Hoffmann wrote:

[ depending on CONFIG_SMP ]

>> Okay, thanks. Yes, I agree such would make sense.
> 
> Patch below.  It simply returns in case the tables are empty and nothing
> is do to, thus avoids printing the confusing message.

It does avoid the message but well, that's also _all_ it avoids. Why do 
you want to do it this way? If I apply the attached, things compile and 
work fine which seems to confirm that, yes, all this smp_alternatives 
code is simply dead baggage on !CONFIG_SMP.

Yes, the #ifdef in arch/i386/kernel/module.c is a bit clumsy. Just proof 
of concept, might be abstracted out a bit better. It does lose most of 
alternatives.c which would seem to be good thing.

Unless I'm missing some points, I believe this code should not be 
compiled in for !CONFIG_SMP.

One other point, although probably not a relevant one. Your changes in 
module_finalize() potentially change behaviour. It used to be:

for (s = sechdrs; s < sechdrs + hdr->e_shnum; s++) {
	void *seg;
	if (strcmp(".altinstructions", secstrings + s->sh_name))
		continue;
	seg = (void *)s->sh_addr;
	apply_alternatives(seg, seg + s->sh_size);
}

which means that any .altinstructions section would be patched. It's now:

for (s = sechdrs; s < sechdrs + hdr->e_shnum; s++) {
	...
	if (!strcmp(".altinstructions", secstrings + s->sh_name))
		alt = s;
	...
}
if (alt) {
	/* patch .altinstructions */
	void *aseg = (void *)alt->sh_addr;
	apply_alternatives(aseg, aseg + alt->sh_size);
}

which means that only the last such section would. I suppose there's 
only one such section anyway, but not seeing a break in the original 
does make me wonder if this was originally done on purpose.

Rene.


[-- Attachment #2: alternatives_no_smp.diff --]
[-- Type: text/plain, Size: 2282 bytes --]

Index: local/arch/i386/kernel/alternative.c
===================================================================
--- local.orig/arch/i386/kernel/alternative.c	2006-05-11 20:28:56.000000000 +0200
+++ local/arch/i386/kernel/alternative.c	2006-05-11 20:32:24.000000000 +0200
@@ -118,6 +118,8 @@ void apply_alternatives(struct alt_instr
 	}
 }
 
+#ifdef CONFIG_SMP
+
 static void alternatives_smp_save(struct alt_instr *start, struct alt_instr *end)
 {
 	struct alt_instr *a;
@@ -283,10 +285,13 @@ void alternatives_smp_switch(int smp)
 	spin_unlock_irqrestore(&smp_alt, flags);
 }
 
+#endif /* CONFIG_SMP */
+
 void __init alternative_instructions(void)
 {
 	apply_alternatives(__alt_instructions, __alt_instructions_end);
 
+#ifdef CONFIG_SMP
 	/* switch to patch-once-at-boottime-only mode and free the
 	 * tables in case we know the number of CPUs will never ever
 	 * change */
@@ -318,4 +323,5 @@ void __init alternative_instructions(voi
 					    _text, _etext);
 		alternatives_smp_switch(0);
 	}
+#endif
 }
Index: local/arch/i386/kernel/module.c
===================================================================
--- local.orig/arch/i386/kernel/module.c	2006-05-11 20:28:56.000000000 +0200
+++ local/arch/i386/kernel/module.c	2006-05-11 20:29:00.000000000 +0200
@@ -112,12 +112,14 @@ int module_finalize(const Elf_Ehdr *hdr,
 	char *secstrings = (void *)hdr + sechdrs[hdr->e_shstrndx].sh_offset;
 
 	for (s = sechdrs; s < sechdrs + hdr->e_shnum; s++) { 
-		if (!strcmp(".text", secstrings + s->sh_name))
-			text = s;
 		if (!strcmp(".altinstructions", secstrings + s->sh_name))
 			alt = s;
+#ifdef CONFIG_SMP
 		if (!strcmp(".smp_locks", secstrings + s->sh_name))
 			locks= s;
+		if (!strcmp(".text", secstrings + s->sh_name))
+			text = s;
+#endif
 	}
 
 	if (alt) {
@@ -126,16 +128,20 @@ int module_finalize(const Elf_Ehdr *hdr,
 		apply_alternatives(aseg, aseg + alt->sh_size);
 	}
 	if (locks && text) {
+#ifdef CONFIG_SMP
 		void *lseg = (void *)locks->sh_addr;
 		void *tseg = (void *)text->sh_addr;
 		alternatives_smp_module_add(me, me->name,
 					    lseg, lseg + locks->sh_size,
 					    tseg, tseg + text->sh_size);
+#endif
 	}
 	return 0;
 }
 
 void module_arch_cleanup(struct module *mod)
 {
+#ifdef CONFIG_SMP
 	alternatives_smp_module_del(mod);
+#endif
 }

  reply	other threads:[~2006-05-11 21:07 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-05-10  0:30 2.6.17-rc3 -- SMP alternatives: switching to UP code Rene Herman
2006-05-10  1:55 ` Chase Venters
2006-05-10  9:28 ` Gerd Hoffmann
2006-05-10 11:41   ` Rene Herman
2006-05-11 12:13     ` [patch] SMP alternatives: skip with UP kernels Gerd Hoffmann
2006-05-11 21:07       ` Rene Herman [this message]
2006-05-12 11:41         ` Gerd Hoffmann
2006-05-15 21:41           ` Rene Herman
  -- strict thread matches above, loose matches on Subject: below --
2006-05-11 16:22 Mikael Pettersson
2006-05-11 18:28 ` Andi Kleen
2006-05-11 21:18 Mikael Pettersson

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=4463A78F.5030703@keyaccess.nl \
    --to=rene.herman@keyaccess.nl \
    --cc=kraxel@suse.de \
    --cc=linux-kernel@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.