2009-01-05 07:12:47

by cheng renquan

[permalink] [raw]
Subject: KPROBE linking error (who's the maintainer of kernel/power/) ?

with this .config
CONFIG_CGROUPS=yCONFIG_CGROUP_FREEZER=yCONFIG_MODULES=yCONFIG_FREEZER=yCONFIG_PM=yCONFIG_PM_SLEEP=n
the kernel will end compiling with error:
kernel/built-in.o: In function `check_safety':/usr/src/linux-2.6.28/kernel/kprobes.c:126: undefined reference to`freeze_processes'/usr/src/linux-2.6.28/kernel/kprobes.c:139: undefined reference to`thaw_processes'/usr/src/linux-2.6.28/kernel/kprobes.c:139: undefined reference to`thaw_processes'make: *** [.tmp_vmlinux1] Error 1
By read kernel/kprobes.c, I found there maybe a bug:
1. "check_safety" in "kernel/kprobes.c" call thaw_processes if bothCONFIG_PREEMPT and CONFIG_PM defined,2. "thaw_processes" function is implemented in "kernel/power/process.c",3. but it is only used if CONFIG_FREEZER defined, from <linux/freezer.h>,4. else (CONFIG_FREEZER undefined) it's a null macro defined in<linux/freezer.h>,5. but process.o only get compile if CONFIG_PM_SLEEP defined, from"kernel/power/Makefile",
Now I'm confused on how to resolve this?What's the relation of PM, PM_SLEEP, and FREEZER?Which modification of the following will be better?1. modify kernel/Kconfig, let KPROBES depends more?2. modify kernel/kprobes.c, let the conditional compile depends more?3. modify include/linux/freezer.h, move thaw_processes to include/linux/pm.h?4. modify kernel/power/Makefile, let kernel/power/process.c compile onless condition?
Furthermore, there seems no entry for maintainers of "kernel/power/",who maintain that subdir please add your name to the MAINTAINERS file?I just grab some latest touchers of kernel/power/ and kernel/kprobes.cas the recipients here.
-- Cheng Renquan (程任全), Shenzhen, ChinaEddie Izzard - "I grew up in Europe, where the history comes from."????{.n?+???????+%?????ݶ??w??{.n?+????{??G?????{ay?ʇڙ?,j??f???h?????????z_??(?階?ݢj"???m??????G????????????&???~???iO???z??v?^?m???? ????????I?


2009-01-05 13:16:03

by Rafael J. Wysocki

[permalink] [raw]
Subject: Re: KPROBE linking error (who's the maintainer of kernel/power/) ?

Hi,

On Monday 05 January 2009, Cheng Renquan (程任全) wrote:
> with this .config
>
> CONFIG_CGROUPS=y
> CONFIG_CGROUP_FREEZER=y
> CONFIG_MODULES=y
> CONFIG_FREEZER=y
> CONFIG_PM=y
> CONFIG_PM_SLEEP=n
>
> the kernel will end compiling with error:
>
> kernel/built-in.o: In function `check_safety':
> /usr/src/linux-2.6.28/kernel/kprobes.c:126: undefined reference to
> `freeze_processes'
> /usr/src/linux-2.6.28/kernel/kprobes.c:139: undefined reference to
> `thaw_processes'
> /usr/src/linux-2.6.28/kernel/kprobes.c:139: undefined reference to
> `thaw_processes'
> make: *** [.tmp_vmlinux1] Error 1

So there is a bug, thanks for the report.

> By read kernel/kprobes.c, I found there maybe a bug:
>
> 1. "check_safety" in "kernel/kprobes.c" call thaw_processes if both
> CONFIG_PREEMPT and CONFIG_PM defined,
> 2. "thaw_processes" function is implemented in "kernel/power/process.c",
> 3. but it is only used if CONFIG_FREEZER defined, from <linux/freezer.h>,
> 4. else (CONFIG_FREEZER undefined) it's a null macro defined in
> <linux/freezer.h>,
> 5. but process.o only get compile if CONFIG_PM_SLEEP defined, from
> "kernel/power/Makefile",
>
> Now I'm confused on how to resolve this?

I'd make process.o depend on CONFIG_FREEZER (patch below).

> What's the relation of PM, PM_SLEEP, and FREEZER?

PM_SLEEP depends on PM and FREEZER is defined in kernel/Kconfig.freezer as

config FREEZER
def_bool PM_SLEEP || CGROUP_FREEZER

> Which modification of the following will be better?
> 1. modify kernel/Kconfig, let KPROBES depends more?
> 2. modify kernel/kprobes.c, let the conditional compile depends more?
> 3. modify include/linux/freezer.h, move thaw_processes to include/linux/pm.h?
> 4. modify kernel/power/Makefile, let kernel/power/process.c compile on
> less condition?
>
> Furthermore, there seems no entry for maintainers of "kernel/power/",
> who maintain that subdir please add your name to the MAINTAINERS file?
> I just grab some latest touchers of kernel/power/ and kernel/kprobes.c
> as the recipients here.

I'm one of the maintainers.

Thanks,
Rafael

---
Subject: PM: Fix freezer compilation if PM_SLEEP is unset
From: Rafael J. Wysocki <[email protected]>

Freezer fails to compile if with the following configuration
settings:

CONFIG_CGROUPS=y
CONFIG_CGROUP_FREEZER=y
CONFIG_MODULES=y
CONFIG_FREEZER=y
CONFIG_PM=y
CONFIG_PM_SLEEP=n

Fix this by making process.o compilation depend on CONFIG_FREEZER.

Reported-by: Cheng Renquan <[email protected]>
Signed-off-by: Rafael J. Wysocki <[email protected]>
---
kernel/power/Makefile | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

Index: linux-2.6/kernel/power/Makefile
===================================================================
--- linux-2.6.orig/kernel/power/Makefile
+++ linux-2.6/kernel/power/Makefile
@@ -4,7 +4,8 @@ EXTRA_CFLAGS += -DDEBUG
endif

obj-y := main.o
-obj-$(CONFIG_PM_SLEEP) += process.o console.o
+obj-$(CONFIG_PM_SLEEP) += console.o
+obj-$(CONFIG_FREEZER) += process.o
obj-$(CONFIG_HIBERNATION) += swsusp.o disk.o snapshot.o swap.o user.o

obj-$(CONFIG_MAGIC_SYSRQ) += poweroff.o

2009-01-05 16:55:50

by cheng renquan

[permalink] [raw]
Subject: Re: KPROBE linking error (who's the maintainer of kernel/power/) ?

On Mon, Jan 5, 2009 at 9:16 PM, Rafael J. Wysocki <[email protected]> wrote:>> Furthermore, there seems no entry for maintainers of "kernel/power/",>> who maintain that subdir please add your name to the MAINTAINERS file?>> I just grab some latest touchers of kernel/power/ and kernel/kprobes.c>> as the recipients here.>> I'm one of the maintainers.
I found that [email protected] by searching youremail in the MAINTAINERS file, in the section of "SUSPEND TO RAM" and"HIBERNATION", both not very apparently related to kernel/power/,maybe my careless, maybe we can improve it?
>> Thanks,> Rafael

-- Cheng Renquan (程任全), Shenzhen, ChinaEddie Izzard - "I grew up in Europe, where the history comes from."????{.n?+???????+%?????ݶ??w??{.n?+????{??G?????{ay?ʇڙ?,j??f???h?????????z_??(?階?ݢj"???m??????G????????????&???~???iO???z??v?^?m???? ????????I?

2009-01-05 19:51:20

by Rafael J. Wysocki

[permalink] [raw]
Subject: Re: KPROBE linking error (who's the maintainer of kernel/power/) ?

On Monday 05 January 2009, Cheng Renquan (程任全) wrote:
> On Mon, Jan 5, 2009 at 9:16 PM, Rafael J. Wysocki <[email protected]> wrote:
> >> Furthermore, there seems no entry for maintainers of "kernel/power/",
> >> who maintain that subdir please add your name to the MAINTAINERS file?
> >> I just grab some latest touchers of kernel/power/ and kernel/kprobes.c
> >> as the recipients here.
> >
> > I'm one of the maintainers.
>
> I found that [email protected] by searching your
> email in the MAINTAINERS file, in the section of "SUSPEND TO RAM" and
> "HIBERNATION", both not very apparently related to kernel/power/,
> maybe my careless, maybe we can improve it?

Well, kernel/power is mostly about hibernation and suspend to RAM, the freezer
is the only "other" thing. It used to be suspend/hibernation-specific, though.

Thanks,
Rafael

2009-01-05 22:11:57

by Masami Hiramatsu

[permalink] [raw]
Subject: [PATCH] kprobes: check CONFIG_FREEZER instead of CONFIG_PM

Hi,

Rafael J. Wysocki wrote:
> On Monday 05 January 2009, Cheng Renquan (程任全) wrote:
>> 1. "check_safety" in "kernel/kprobes.c" call thaw_processes if both
>> CONFIG_PREEMPT and CONFIG_PM defined,
>> 2. "thaw_processes" function is implemented in "kernel/power/process.c",
>> 3. but it is only used if CONFIG_FREEZER defined, from <linux/freezer.h>,
>> 4. else (CONFIG_FREEZER undefined) it's a null macro defined in
>> <linux/freezer.h>,
>> 5. but process.o only get compile if CONFIG_PM_SLEEP defined, from
>> "kernel/power/Makefile",
>>
>> Now I'm confused on how to resolve this?
>
> I'd make process.o depend on CONFIG_FREEZER (patch below).

Thank you for fixing.
In addition, I think that kprobes also should check CONFIG_FREEZER
instead of CONFIG_PM.
---
From: Masami Hiramatsu <[email protected]>

Check CONFIG_FREEZER instead of CONFIG_PM because kprobe booster
depends on freeze_processes() and thaw_processes() when CONFIG_PREEMPT=y.

This fixes a linkage error which occurs when CONFIG_PREEMPT=y, CONFIG_PM=y
and CONFIG_FREEZER=n.

Reported-by: Cheng Renquan <[email protected]>
Signed-off-by: Masami Hiramatsu <[email protected]>
---
arch/ia64/kernel/kprobes.c | 2 +-
arch/x86/kernel/kprobes.c | 2 +-
kernel/kprobes.c | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)

Index: 2.6.28/arch/ia64/kernel/kprobes.c
===================================================================
--- 2.6.28.orig/arch/ia64/kernel/kprobes.c
+++ 2.6.28/arch/ia64/kernel/kprobes.c
@@ -868,7 +868,7 @@ static int __kprobes pre_kprobes_handler
return 1;

ss_probe:
-#if !defined(CONFIG_PREEMPT) || defined(CONFIG_PM)
+#if !defined(CONFIG_PREEMPT) || defined(CONFIG_FREEZER)
if (p->ainsn.inst_flag == INST_FLAG_BOOSTABLE && !p->post_handler) {
/* Boost up -- we can execute copied instructions directly */
ia64_psr(regs)->ri = p->ainsn.slot;
Index: 2.6.28/arch/x86/kernel/kprobes.c
===================================================================
--- 2.6.28.orig/arch/x86/kernel/kprobes.c
+++ 2.6.28/arch/x86/kernel/kprobes.c
@@ -445,7 +445,7 @@ void __kprobes arch_prepare_kretprobe(st
static void __kprobes setup_singlestep(struct kprobe *p, struct pt_regs *regs,
struct kprobe_ctlblk *kcb)
{
-#if !defined(CONFIG_PREEMPT) || defined(CONFIG_PM)
+#if !defined(CONFIG_PREEMPT) || defined(CONFIG_FREEZER)
if (p->ainsn.boostable == 1 && !p->post_handler) {
/* Boost up -- we can execute copied instructions directly */
reset_current_kprobe();
Index: 2.6.28/kernel/kprobes.c
===================================================================
--- 2.6.28.orig/kernel/kprobes.c
+++ 2.6.28/kernel/kprobes.c
@@ -122,7 +122,7 @@ static int collect_garbage_slots(void);
static int __kprobes check_safety(void)
{
int ret = 0;
-#if defined(CONFIG_PREEMPT) && defined(CONFIG_PM)
+#if defined(CONFIG_PREEMPT) && defined(CONFIG_FREEZER)
ret = freeze_processes();
if (ret == 0) {
struct task_struct *p, *q;



--
Masami Hiramatsu

Software Engineer
Hitachi Computer Products (America) Inc.
Software Solutions Division

e-mail: [email protected]

2009-01-06 08:49:11

by Pavel Machek

[permalink] [raw]
Subject: Re: KPROBE linking error (who's the maintainer of kernel/power/) ?

> Hi,
>
> On Monday 05 January 2009, Cheng Renquan (?????????) wrote:
> > with this .config
> >
> > CONFIG_CGROUPS=y
> > CONFIG_CGROUP_FREEZER=y
> > CONFIG_MODULES=y
> > CONFIG_FREEZER=y
> > CONFIG_PM=y
> > CONFIG_PM_SLEEP=n
> >
> > the kernel will end compiling with error:
> >
> > kernel/built-in.o: In function `check_safety':
> > /usr/src/linux-2.6.28/kernel/kprobes.c:126: undefined reference to
> > `freeze_processes'
> > /usr/src/linux-2.6.28/kernel/kprobes.c:139: undefined reference to
> > `thaw_processes'
> > /usr/src/linux-2.6.28/kernel/kprobes.c:139: undefined reference to
> > `thaw_processes'
> > make: *** [.tmp_vmlinux1] Error 1
>
> So there is a bug, thanks for the report.
>
> > By read kernel/kprobes.c, I found there maybe a bug:
> >
> > 1. "check_safety" in "kernel/kprobes.c" call thaw_processes if both
> > CONFIG_PREEMPT and CONFIG_PM defined,
> > 2. "thaw_processes" function is implemented in "kernel/power/process.c",
> > 3. but it is only used if CONFIG_FREEZER defined, from <linux/freezer.h>,
> > 4. else (CONFIG_FREEZER undefined) it's a null macro defined in
> > <linux/freezer.h>,
> > 5. but process.o only get compile if CONFIG_PM_SLEEP defined, from
> > "kernel/power/Makefile",
> >
> > Now I'm confused on how to resolve this?
>
> I'd make process.o depend on CONFIG_FREEZER (patch below).
>
> > What's the relation of PM, PM_SLEEP, and FREEZER?
>
> PM_SLEEP depends on PM and FREEZER is defined in kernel/Kconfig.freezer as
>
> config FREEZER
> def_bool PM_SLEEP || CGROUP_FREEZER
>
> > Which modification of the following will be better?
> > 1. modify kernel/Kconfig, let KPROBES depends more?
> > 2. modify kernel/kprobes.c, let the conditional compile depends more?
> > 3. modify include/linux/freezer.h, move thaw_processes to include/linux/pm.h?
> > 4. modify kernel/power/Makefile, let kernel/power/process.c compile on
> > less condition?
> >
> > Furthermore, there seems no entry for maintainers of "kernel/power/",
> > who maintain that subdir please add your name to the MAINTAINERS file?
> > I just grab some latest touchers of kernel/power/ and kernel/kprobes.c
> > as the recipients here.
>
> I'm one of the maintainers.
>
> Thanks,
> Rafael
>
> ---
> Subject: PM: Fix freezer compilation if PM_SLEEP is unset
> From: Rafael J. Wysocki <[email protected]>
>
> Freezer fails to compile if with the following configuration
> settings:
>
> CONFIG_CGROUPS=y
> CONFIG_CGROUP_FREEZER=y
> CONFIG_MODULES=y
> CONFIG_FREEZER=y
> CONFIG_PM=y
> CONFIG_PM_SLEEP=n
>
> Fix this by making process.o compilation depend on CONFIG_FREEZER.
>
> Reported-by: Cheng Renquan <[email protected]>
> Signed-off-by: Rafael J. Wysocki <[email protected]>

Acked-by: Pavel Machek <[email protected]>

> ---
> kernel/power/Makefile | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> Index: linux-2.6/kernel/power/Makefile
> ===================================================================
> --- linux-2.6.orig/kernel/power/Makefile
> +++ linux-2.6/kernel/power/Makefile
> @@ -4,7 +4,8 @@ EXTRA_CFLAGS += -DDEBUG
> endif
>
> obj-y := main.o
> -obj-$(CONFIG_PM_SLEEP) += process.o console.o
> +obj-$(CONFIG_PM_SLEEP) += console.o
> +obj-$(CONFIG_FREEZER) += process.o
> obj-$(CONFIG_HIBERNATION) += swsusp.o disk.o snapshot.o swap.o user.o
>
> obj-$(CONFIG_MAGIC_SYSRQ) += poweroff.o
>
>

--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html