Skip to contentSkip to conversation

kbuild: fixing the select problem

DISCUSSION James Bottomley 7 participants 13 messages May 5, 2010 – May 7, 2010

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

[Sam: I know you don't maintain kbuild anymore, but since you have the most experience, if you could find time to comment, I'd be grateful]

The select problem is that the kbuild select directive will turn a symbol on without reference to its dependencies. This, in turn, means that either selected symbols must select their dependencies, or that people using select have to be aware of the selected symbol's dependency and build those dependencies into their symbol (leading to duplication and the possibility of getting the dependencies out of sync). We use select for the scsi transport classes, so we run into this problem in SCSI quite a lot.

I think the correct fix is to make a symbol that selects another symbol automatically inherit all of the selected symbol's dependencies.

There seems to be a fairly easy way to do this in kbuild. Right at the moment, select is handled as additional symbol values as the last point in the symbol tree evaluation process. Instead, what I propose doing is for every select symbol, we add an extra unconditional default for the selected symbol of the selecting symbol's current value (this breaks a possible dependency cycle) and add to the dependencies of the selecting symbol, the symbol it's currently selecting.

There's one wrinkle to all of this in that the current parser for default values stops when it finds the first valid (i.e. whose if clause evaluates to true) default. To make the above scheme work, I need to modify the default parser so it takes the highest tristate of all the valid defaults (and bumps m to y for bool).

Does this look acceptable to people? I think it should give the desired result and has the added benefit that we can then strip the extra select overlay out of the kbuild system (making the parser slightly simpler).

If this looks like a good idea to people, I think I can code up a quick patch.

James

#1 lore raw
Quoted 12 lines · James Bottomley

[Sam: I know you don't maintain kbuild anymore, but since you have the most experience, if you could find time to comment, I'd be grateful]

The select problem is that the kbuild select directive will turn a symbol on without reference to its dependencies.  This, in turn, means that either selected symbols must select their dependencies, or that people using select have to be aware of the selected symbol's dependency and build those dependencies into their symbol (leading to duplication and the possibility of getting the dependencies out of sync).  We use select for the scsi transport classes, so we run into this problem in SCSI quite a lot.

Quoted 2 lines

I think the correct fix is to make a symbol that selects another symbol automatically inherit all of the selected symbol's dependencies.

What if there's a good reason the selected symbol has this dependency? E.g. it depends on a critical feature not available? Like CONFIG_HAS_IOMEM?

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#2 lore raw
Quoted 14 lines · Geert Uytterhoeven
Quoted 12 lines · James Bottomley

[Sam: I know you don't maintain kbuild anymore, but since you have the most experience, if you could find time to comment, I'd be grateful]

The select problem is that the kbuild select directive will turn a symbol on without reference to its dependencies. This, in turn, means that either selected symbols must select their dependencies, or that people using select have to be aware of the selected symbol's dependency and build those dependencies into their symbol (leading to duplication and the possibility of getting the dependencies out of sync). We use select for the scsi transport classes, so we run into this problem in SCSI quite a lot.

Quoted 5 lines
Quoted 2 lines

I think the correct fix is to make a symbol that selects another symbol automatically inherit all of the selected symbol's dependencies.

What if there's a good reason the selected symbol has this dependency? E.g. it depends on a critical feature not available? Like CONFIG_HAS_IOMEM?

I don't quite understand the question. If a selected symbol has a critical dependency which is config'd to N then the build usually breaks ... that's what I'm calling the select problem. I thought CONFIG_HAS_IOMEM was usually selected by the architecture, though. In the new proposal, we wouldn't be able to generate the invalid configuration in the first place.

James

#3 lore raw
Quoted 21 lines · James Bottomley
Quoted 14 lines · Geert Uytterhoeven
Quoted 12 lines · James Bottomley

[Sam: I know you don't maintain kbuild anymore, but since you have the most experience, if you could find time to comment, I'd be grateful]

The select problem is that the kbuild select directive will turn a symbol on without reference to its dependencies.  This, in turn, means that either selected symbols must select their dependencies, or that people using select have to be aware of the selected symbol's dependency and build those dependencies into their symbol (leading to duplication and the possibility of getting the dependencies out of sync).  We use select for the scsi transport classes, so we run into this problem in SCSI quite a lot.

Quoted 5 lines
Quoted 2 lines

I think the correct fix is to make a symbol that selects another symbol automatically inherit all of the selected symbol's dependencies.

What if there's a good reason the selected symbol has this dependency? E.g. it depends on a critical feature not available? Like CONFIG_HAS_IOMEM?

Quoted 6 lines

I don't quite understand the question.  If a selected symbol has a critical dependency which is config'd to N then the build usually breaks ... that's what I'm calling the select problem.  I thought CONFIG_HAS_IOMEM was usually selected by the architecture, though.  In the new proposal, we wouldn't be able to generate the invalid configuration in the first place.

Sorry, my fault, -EREPLY_TOO_EARLY_AFTER_WAKEUP.
Upon rereading what you actually wrote, it made complete sense, and my question didn't.

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

#6 lore raw
In reply to James Bottomley
Quoted 15 lines · James Bottomley

[Sam: I know you don't maintain kbuild anymore, but since you have the most experience, if you could find time to comment, I'd be grateful]

The select problem is that the kbuild select directive will turn a symbol on without reference to its dependencies. This, in turn, means that either selected symbols must select their dependencies, or that people using select have to be aware of the selected symbol's dependency and build those dependencies into their symbol (leading to duplication and the possibility of getting the dependencies out of sync). We use select for the scsi transport classes, so we run into this problem in SCSI quite a lot.

I think the correct fix is to make a symbol that selects another symbol automatically inherit all of the selected symbol's dependencies.

Quoted 7 lines

There seems to be a fairly easy way to do this in kbuild. Right at the moment, select is handled as additional symbol values as the last point in the symbol tree evaluation process. Instead, what I propose doing is for every select symbol, we add an extra unconditional default for the selected symbol of the selecting symbol's current value (this breaks a possible dependency cycle) and add to the dependencies of the selecting symbol, the symbol it's currently selecting.

Nice trick :-).

Quoted 5 lines

There's one wrinkle to all of this in that the current parser for default values stops when it finds the first valid (i.e. whose if clause evaluates to true) default. To make the above scheme work, I need to modify the default parser so it takes the highest tristate of all the valid defaults (and bumps m to y for bool).

We should check if some Kconfig file doesn't rely on this "first hit" behavior and fix it to explicitly list the condition for a given default. Another option would be to add
default SYM1 || SYM2
to a symbol selected by SYM1 and SYM2.

Quoted 6 lines

Does this look acceptable to people? I think it should give the desired result and has the added benefit that we can then strip the extra select overlay out of the kbuild system (making the parser slightly simpler).

If this looks like a good idea to people, I think I can code up a quick patch.

Other than the above, right now I don't see any issues with such approach.

On a related note, I see Vegard's GSoC project to use a sat solver for kconfig got accepted [1]. Vegard, how is the project progressing?

[1]
http://socghop.appspot.com/gsoc/student_project/show/google/gsoc2010/psu_home/t127230762803

Michal

#7 lore raw
Quoted 33 lines · Michal Marek
Quoted 15 lines · James Bottomley

[Sam: I know you don't maintain kbuild anymore, but since you have the most experience, if you could find time to comment, I'd be grateful]

The select problem is that the kbuild select directive will turn a symbol on without reference to its dependencies. This, in turn, means that either selected symbols must select their dependencies, or that people using select have to be aware of the selected symbol's dependency and build those dependencies into their symbol (leading to duplication and the possibility of getting the dependencies out of sync). We use select for the scsi transport classes, so we run into this problem in SCSI quite a lot.

I think the correct fix is to make a symbol that selects another symbol automatically inherit all of the selected symbol's dependencies.

Quoted 7 lines

There seems to be a fairly easy way to do this in kbuild. Right at the moment, select is handled as additional symbol values as the last point in the symbol tree evaluation process. Instead, what I propose doing is for every select symbol, we add an extra unconditional default for the selected symbol of the selecting symbol's current value (this breaks a possible dependency cycle) and add to the dependencies of the selecting symbol, the symbol it's currently selecting.

Nice trick :-).

Quoted 5 lines

There's one wrinkle to all of this in that the current parser for default values stops when it finds the first valid (i.e. whose if clause evaluates to true) default. To make the above scheme work, I need to modify the default parser so it takes the highest tristate of all the valid defaults (and bumps m to y for bool).

Quoted 3 lines

We should check if some Kconfig file doesn't rely on this "first hit" behavior and fix it to explicitly list the condition for a given default.

I actually asked kconfig to generate the list of symbols (in my config) with multiple defaults. It's pretty small and the default y seems to be the thing with multiple if clauses, so they act like or statements.

The list is

USB_ARCH_HAS_HCD has 4 defaults
DEFCONFIG_LIST has 5 defaults
MAC80211_RC_DEFAULT has 2 defaults
X86_L1_CACHE_SHIFT has 2 defaults
SPLIT_PTLOCK_CPUS has 2 defaults
X86_MINIMUM_CPU_FAMILY has 3 defaults
DEFAULT_TCP_CONG has 2 defaults
DEFCONFIG_LIST has 5 defaults
USB_ARCH_HAS_HCD has 4 defaults
X86_L1_CACHE_SHIFT has 2 defaults
X86_MINIMUM_CPU_FAMILY has 3 defaults
SPLIT_PTLOCK_CPUS has 2 defaults
DEFAULT_TCP_CONG has 2 defaults
MAC80211_RC_DEFAULT has 2 defaults

Quoted 3 lines

Another option would be to add
default SYM1 || SYM2
to a symbol selected by SYM1 and SYM2.

Well, that's effectively what the proposal does (it or's the states).

Quoted 9 lines
Quoted 6 lines

Does this look acceptable to people? I think it should give the desired result and has the added benefit that we can then strip the extra select overlay out of the kbuild system (making the parser slightly simpler).

If this looks like a good idea to people, I think I can code up a quick patch.

Other than the above, right now I don't see any issues with such approach.

Quoted 7 lines

On a related note, I see Vegard's GSoC project to use a sat solver for kconfig got accepted [1]. Vegard, how is the project progressing?

[1]
http://socghop.appspot.com/gsoc/student_project/show/google/gsoc2010/psu_home/t127230762803

Michal

James

#4 lore raw
In reply to James Bottomley
Quoted 21 lines · James Bottomley
Quoted 14 lines · Geert Uytterhoeven
Quoted 12 lines · James Bottomley

[Sam: I know you don't maintain kbuild anymore, but since you have the most experience, if you could find time to comment, I'd be grateful]

The select problem is that the kbuild select directive will turn a symbol on without reference to its dependencies. This, in turn, means that either selected symbols must select their dependencies, or that people using select have to be aware of the selected symbol's dependency and build those dependencies into their symbol (leading to duplication and the possibility of getting the dependencies out of sync). We use select for the scsi transport classes, so we run into this problem in SCSI quite a lot.

Quoted 5 lines
Quoted 2 lines

I think the correct fix is to make a symbol that selects another symbol automatically inherit all of the selected symbol's dependencies.

What if there's a good reason the selected symbol has this dependency? E.g. it depends on a critical feature not available? Like CONFIG_HAS_IOMEM?

Quoted 6 lines

I don't quite understand the question. If a selected symbol has a critical dependency which is config'd to N then the build usually breaks ... that's what I'm calling the select problem. I thought CONFIG_HAS_IOMEM was usually selected by the architecture, though. In the new proposal, we wouldn't be able to generate the invalid configuration in the first place.

I think Geert is asking "If the arch says CONFIG_HAS_IOMEM=n, but some driver does a 'select CONFIG_FOO' which then (under your proposal) forces the value CONFIG_BAR=y, which eventually ends up with CONFIG_HAS_IOMEM=y, what should the behavior be?"

(I suspect the right answer here is "one of the symbols is buggy and its 'select' should be a 'depends' instead", but somebody else better double-check that conclusion - I'm hardly a Kconfig expert).

#11 lore raw
In reply to Michal Marek
Quoted 5 lines · Michal Marek

On a related note, I see Vegard's GSoC project to use a sat solver for kconfig got accepted [1]. Vegard, how is the project progressing?

[1]
http://socghop.appspot.com/gsoc/student_project/show/google/gsoc2010/psu_home/t127230762803

Hi,

Yes, that is true :-) I was planning to send an announcement to LKML this weekend. Actual coding doesn't start until the last week of May.

So hopefully we can soon get rid of select altogether :-)

Vegard

#5 lore raw
In reply to [email protected]
Quoted 29 lines · On Thu, May 6, 2010 at 18:47, <[email protected]> wrote:
Quoted 21 lines · James Bottomley
Quoted 14 lines · Geert Uytterhoeven
Quoted 12 lines · James Bottomley

[Sam: I know you don't maintain kbuild anymore, but since you have the most experience, if you could find time to comment, I'd be grateful]

The select problem is that the kbuild select directive will turn a symbol on without reference to its dependencies.  This, in turn, means that either selected symbols must select their dependencies, or that people using select have to be aware of the selected symbol's dependency and build those dependencies into their symbol (leading to duplication and the possibility of getting the dependencies out of sync).  We use select for the scsi transport classes, so we run into this problem in SCSI quite a lot.

Quoted 5 lines
Quoted 2 lines

I think the correct fix is to make a symbol that selects another symbol automatically inherit all of the selected symbol's dependencies.

What if there's a good reason the selected symbol has this dependency? E.g. it depends on a critical feature not available? Like CONFIG_HAS_IOMEM?

Quoted 6 lines

I don't quite understand the question.  If a selected symbol has a critical dependency which is config'd to N then the build usually breaks ... that's what I'm calling the select problem.  I thought CONFIG_HAS_IOMEM was usually selected by the architecture, though.  In the new proposal, we wouldn't be able to generate the invalid configuration in the first place.

Quoted 4 lines

I think Geert is asking "If the arch says CONFIG_HAS_IOMEM=n, but some driver does a 'select CONFIG_FOO' which then (under your proposal) forces the value CONFIG_BAR=y, which eventually ends up with CONFIG_HAS_IOMEM=y, what should the behavior be?"

Yep, that was my (bogus) question...

Quoted 3 lines

(I suspect the right answer here is "one of the symbols is buggy and its 'select' should be a 'depends' instead", but somebody else better double-check that conclusion - I'm hardly a Kconfig expert).

No, the CONFIG_FOO will inherit the dependency on CONFIG_HAS_IOMEM.

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#8 lore raw
In reply to James Bottomley
Quoted 16 lines · James Bottomley

The list is

USB_ARCH_HAS_HCD has 4 defaults DEFCONFIG_LIST has 5 defaults MAC80211_RC_DEFAULT has 2 defaults X86_L1_CACHE_SHIFT has 2 defaults SPLIT_PTLOCK_CPUS has 2 defaults X86_MINIMUM_CPU_FAMILY has 3 defaults DEFAULT_TCP_CONG has 2 defaults DEFCONFIG_LIST has 5 defaults USB_ARCH_HAS_HCD has 4 defaults X86_L1_CACHE_SHIFT has 2 defaults X86_MINIMUM_CPU_FAMILY has 3 defaults SPLIT_PTLOCK_CPUS has 2 defaults DEFAULT_TCP_CONG has 2 defaults MAC80211_RC_DEFAULT has 2 defaults

Here's a patch that alters the default processing to the needed form and checks the old vs new values. I've been running randconfigs but I can't get the warning to trip ... have at it.

James

---

scripts/kconfig/symbol.c +21 -4
index 6c8fbbb..722bc4e 100644
@@ -115,14 +115,31 @@ struct property *sym_get_env_prop(struct symbol *sym)
 
 struct property *sym_get_default_prop(struct symbol *sym)
 {
-	struct property *prop;
+	struct property *prop, *ret = NULL;
+	tristate old_val = no, val = no;
 
 	for_all_defaults(sym, prop) {
 		prop->visible.tri = expr_calc_value(prop->visible.expr);
-		if (prop->visible.tri != no)
-			return prop;
+		if (prop->visible.tri != no) {
+			tristate v = expr_calc_value(prop->expr);
+			if (!ret)
+				old_val = v;
+			if (v >= val) {
+				val = v;
+				ret = prop;
+			}
+		}
 	}
-	return NULL;
+	/*
+	 * Previously, we took the first valid default we found (this
+	 * is now old_val).  In the new scheme, the value is the or of
+	 * all the defaults.
+	 */
+	if (old_val != val)
+		menu_warn(ret->menu, "ERROR: new parser has inconsistent "
+			  "values for %s (%d != %d)\n", sym->name,
+			  old_val, val);
+	return ret;
 }
 
 static struct property *sym_get_range_prop(struct symbol *sym)
#9 lore raw
Quoted 18 lines · On Thu, 06 May 2010 15:48:35 -0500 James Bottomley wrote:
Quoted 16 lines · James Bottomley

The list is

USB_ARCH_HAS_HCD has 4 defaults DEFCONFIG_LIST has 5 defaults MAC80211_RC_DEFAULT has 2 defaults X86_L1_CACHE_SHIFT has 2 defaults SPLIT_PTLOCK_CPUS has 2 defaults X86_MINIMUM_CPU_FAMILY has 3 defaults DEFAULT_TCP_CONG has 2 defaults DEFCONFIG_LIST has 5 defaults USB_ARCH_HAS_HCD has 4 defaults X86_L1_CACHE_SHIFT has 2 defaults X86_MINIMUM_CPU_FAMILY has 3 defaults SPLIT_PTLOCK_CPUS has 2 defaults DEFAULT_TCP_CONG has 2 defaults MAC80211_RC_DEFAULT has 2 defaults

Quoted 4 lines

Here's a patch that alters the default processing to the needed form and checks the old vs new values. I've been running randconfigs but I can't get the warning to trip ... have at it.

I don't see the warning, but I took a problem config from linux-next 2010-0506 (today) [attached]. In it, CONFIG_TCG_BIOS_LOG=y and that selects ACPI, so now ACPI is enabled, but ACPI depends on PM and PCI, but they are still not selected...

or is this only step 1 of a multi-step implementation?

Quoted 33 lines

---

scripts/kconfig/symbol.c +14 -4
index 6c8fbbb..722bc4e 100644
@@ -115,14 +115,31 @@ struct property *sym_get_env_prop(struct symbol *sym)
 
 struct property *sym_get_default_prop(struct symbol *sym)
 {
-	struct property *prop;
+	struct property *prop, *ret = NULL;
+	tristate old_val = no, val = no;
 
 	for_all_defaults(sym, prop) {
 		prop->visible.tri = expr_calc_value(prop->visible.expr);
-		if (prop->visible.tri != no)
-			return prop;
+		if (prop->visible.tri != no) {
+			tristate v = expr_calc_value(prop->expr);
+			if (!ret)
+				old_val = v;
+			if (v >= val) {
+				val = v;
+				ret = prop;
+			}
+		}
 	}
-	return NULL;
+	/*
+	 * Previously, we took the first valid default we found (this
+	 * is now old_val).  In the new scheme, the value is the or of

scripts/kconfig/symbol.c struct property *sym_get_env_prop(struct symbol *sym) · line 145

Quoted 10 lines
scripts/kconfig/symbol.c +7 -0
+	 * all the defaults.
+	 */
+	if (old_val != val)
+		menu_warn(ret->menu, "ERROR: new parser has inconsistent "
+			  "values for %s (%d != %d)\n", sym->name,
+			  old_val, val);
+	return ret;
 }
 
 static struct property *sym_get_range_prop(struct symbol *sym)

---
~Randy
*** Remember to use Documentation/SubmitChecklist when testing your code ***

#10 lore raw
Quoted 25 lines · Randy Dunlap
Quoted 18 lines · On Thu, 06 May 2010 15:48:35 -0500 James Bottomley wrote:
Quoted 16 lines · James Bottomley

The list is

USB_ARCH_HAS_HCD has 4 defaults DEFCONFIG_LIST has 5 defaults MAC80211_RC_DEFAULT has 2 defaults X86_L1_CACHE_SHIFT has 2 defaults SPLIT_PTLOCK_CPUS has 2 defaults X86_MINIMUM_CPU_FAMILY has 3 defaults DEFAULT_TCP_CONG has 2 defaults DEFCONFIG_LIST has 5 defaults USB_ARCH_HAS_HCD has 4 defaults X86_L1_CACHE_SHIFT has 2 defaults X86_MINIMUM_CPU_FAMILY has 3 defaults SPLIT_PTLOCK_CPUS has 2 defaults DEFAULT_TCP_CONG has 2 defaults MAC80211_RC_DEFAULT has 2 defaults

Quoted 4 lines

Here's a patch that alters the default processing to the needed form and checks the old vs new values. I've been running randconfigs but I can't get the warning to trip ... have at it.

Quoted 6 lines

I don't see the warning, but I took a problem config from linux-next 2010-0506 (today) [attached]. In it, CONFIG_TCG_BIOS_LOG=y and that selects ACPI, so now ACPI is enabled, but ACPI depends on PM and PCI, but they are still not selected...

or is this only step 1 of a multi-step implementation?

Actually, it's not any step. It's just validation of the contention that I can alter the default parser from taking the first valid default to calculating the or of the defaults without changing the current kbuild behaviour.

The patch to fix kbuild goes on top of this change minus the warnings (when I actually code it up).

James

#12 lore raw
In reply to James Bottomley
Quoted 11 lines · James Bottomley

The select problem is that the kbuild select directive will turn a symbol on without reference to its dependencies. This, in turn, means that either selected symbols must select their dependencies, or that people using select have to be aware of the selected symbol's dependency and build those dependencies into their symbol (leading to duplication and the possibility of getting the dependencies out of sync). We use select for the scsi transport classes, so we run into this problem in SCSI quite a lot.

I think the correct fix is to make a symbol that selects another symbol automatically inherit all of the selected symbol's dependencies.

You may want to have a look at a patch I proposed some time ago, which at just warns of selecting options with unmet dependencies. I think it's a better approach that forcing the selection of the dependencies:

http://lkml.org/lkml/2009/9/16/413

Signature · 1 line
Catalin