Skip to contentSkip to conversation

USB: hub: Delete an error message for a failed memory allocation in usb_hub_clear_tt_buffer()

PATCH In review SF Markus Elfring 7 participants 25 messages Dec 6, 2017 – Dec 8, 2017

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

PATCH 1/1 USB: hub: Delete an error message for a failed memory allocation in usb_hub_clear_tt_buffer()

From: Markus Elfring <[email protected]>
Date: Wed, 6 Dec 2017 17:00:18 +0100

Omit an extra message for a memory allocation failure in this function.

This issue was detected by using the Coccinelle software.

---
 drivers/usb/core/hub.c | 1 -
 1 file changed, 1 deletion(-)
drivers/usb/core/hub.c +0 -1
index 7ccdd3d4db84..9fbb908e9552 100644
@@ -829,7 +829,6 @@ int usb_hub_clear_tt_buffer(struct urb *urb)
 	 */
 	clear = kmalloc(sizeof *clear, GFP_ATOMIC);
 	if (clear = NULL) {
-		dev_err(&udev->dev, "can't save CLEAR_TT_BUFFER state\n");
 		/* FIXME recover somehow ... RESET_TT? */
 		return -ENOMEM;
 	}
Signature · 1 line
2.15.1
#1 lore raw
Quoted 17 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Wed, 6 Dec 2017 17:00:18 +0100

Omit an extra message for a memory allocation failure in this function.

This issue was detected by using the Coccinelle software.

---
 drivers/usb/core/hub.c | 1 -
 1 file changed, 1 deletion(-)
drivers/usb/core/hub.c +0 -0
index 7ccdd3d4db84..9fbb908e9552 100644

drivers/usb/core/hub.c int usb_hub_clear_tt_buffer(struct urb *urb) · line 834

Quoted 7 lines
drivers/usb/core/hub.c +0 -1
@@ -829,7 +829,6 @@ int usb_hub_clear_tt_buffer(struct urb *urb)
 	 */
 	clear = kmalloc(sizeof *clear, GFP_ATOMIC);
 	if (clear = NULL) {
-		dev_err(&udev->dev, "can't save CLEAR_TT_BUFFER state\n");
 		/* FIXME recover somehow ... RESET_TT? */
 		return -ENOMEM;
 	}

Does the existing memory allocation error message include the &udev->dev device name and driver name? If it doesn't, there will be no way for the user to tell that the error message is related to the device failure.

Alan Stern

#2 lore raw
Quoted 23 lines · Alan Stern
Quoted 21 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Wed, 6 Dec 2017 17:00:18 +0100

Omit an extra message for a memory allocation failure in this function.

This issue was detected by using the Coccinelle software.

---
 drivers/usb/core/hub.c | 1 -
 1 file changed, 1 deletion(-)
drivers/usb/core/hub.c +0 -1
index 7ccdd3d4db84..9fbb908e9552 100644
@@ -829,7 +829,6 @@ int usb_hub_clear_tt_buffer(struct urb *urb)
 	 */
 	clear = kmalloc(sizeof *clear, GFP_ATOMIC);
 	if (clear == NULL) {
-		dev_err(&udev->dev, "can't save CLEAR_TT_BUFFER state\n");
Quoted 8 lines

drivers/usb/core/hub.c int usb_hub_clear_tt_buffer(struct urb *urb) · line 834

Quoted 3 lines
drivers/usb/core/hub.c +0 -0
 		/* FIXME recover somehow ... RESET_TT? */
 		return -ENOMEM;
 	}

Does the existing memory allocation error message include the &udev->dev device name and driver name? If it doesn't, there will be no way for the user to tell that the error message is related to the device failure.

Don't worry, I have a filter for this person's emails and do not see their patches so they will not get applied.

thanks,

greg k-h

#3 lore raw
In reply to Alan Stern

Hi Alan,

Quoted 23 lines · Alan Stern
Quoted 21 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Wed, 6 Dec 2017 17:00:18 +0100

Omit an extra message for a memory allocation failure in this function.

This issue was detected by using the Coccinelle software.

---
 drivers/usb/core/hub.c | 1 -
 1 file changed, 1 deletion(-)
drivers/usb/core/hub.c +0 -1
index 7ccdd3d4db84..9fbb908e9552 100644
@@ -829,7 +829,6 @@ int usb_hub_clear_tt_buffer(struct urb *urb)
       */
      clear = kmalloc(sizeof *clear, GFP_ATOMIC);
      if (clear = NULL) {
-             dev_err(&udev->dev, "can't save CLEAR_TT_BUFFER state\n");
Quoted 8 lines

drivers/usb/core/hub.c int usb_hub_clear_tt_buffer(struct urb *urb) · line 834

Quoted 3 lines
drivers/usb/core/hub.c +0 -0
              /* FIXME recover somehow ... RESET_TT? */
              return -ENOMEM;
      }

Does the existing memory allocation error message include the &udev->dev device name and driver name? If it doesn't, there will be no way for the user to tell that the error message is related to the device failure.

The system will come to a grinding halt anyway if it can't allocate 24 or 40 bytes. Which is BTW more or less the amount of memory saved by killing the useless (error) message.

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

#4 lore raw
Quoted 1 line

The system will come to a grinding halt anyway if it can't allocate 24 or 40 bytes.

Maybe.

Quoted 2 lines

Which is BTW more or less the amount of memory saved by killing the useless (error) message.

Would you dare to resend this update suggestion after such a view?

Regards,
Markus

#5 lore raw

Hi Markus,

Quoted 3 lines · SF Markus Elfring
Quoted 1 line

The system will come to a grinding halt anyway if it can't allocate 24 or 40 bytes.

Maybe.

Since you've been sending zillions of patches for this, perhaps the time is ripe to actually try to trigger this, and see what happens?

Quoted 4 lines
Quoted 2 lines

Which is BTW more or less the amount of memory saved by killing the useless (error) message.

Would you dare to resend this update suggestion after such a view?

Of course. That was implied.

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
Quoted 11 lines · Geert Uytterhoeven

Hi Markus,

Quoted 3 lines · SF Markus Elfring
Quoted 1 line

The system will come to a grinding halt anyway if it can't allocate 24 or 40 bytes.

Maybe.

Since you've been sending zillions of patches for this, perhaps the time is ripe to actually try to trigger this, and see what happens?

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

Which is BTW more or less the amount of memory saved by killing the useless (error) message.

Would you dare to resend this update suggestion after such a view?

Of course. That was implied.

No. Greg maintains USB and he's has blocked Markus, because he never listens to feedback but instead just repsonds that he has a different opinion.

regards,
dan carpenter

#7 lore raw

Re: USB: hub: Checking communication difficulties

Quoted 1 line

Greg maintains USB and he's has blocked Markus,

How do you think about to reconsider this blockage?

Quoted 1 line

because he never listens to feedback

I am listening …

Quoted 1 line

but instead just repsonds that he has a different opinion.

I choose such a reaction in some cases. My responses can vary.

It seems that I show change possibilities from which contributors can get grumpy (over time).

Regards,
Markus
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" 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 Alan Stern
Quoted 2 lines · Alan Stern
Quoted 1 line · SF Markus Elfring

Omit an extra message for a memory allocation failure in this function.

Markus' typical terrible commit message.

Quoted 1 line

drivers/usb/core/hub.c

Quoted 1 line
drivers/usb/core/hub.c +0 -0

[]

Quoted 5 lines
Quoted 5 lines
drivers/usb/core/hub.c +0 -1
@@ -829,7 +829,6 @@ int usb_hub_clear_tt_buffer(struct urb *urb)
       */
      clear = kmalloc(sizeof *clear, GFP_ATOMIC);
      if (clear = NULL) {
-             dev_err(&udev->dev, "can't save CLEAR_TT_BUFFER state\n");
Quoted 8 lines

drivers/usb/core/hub.c int usb_hub_clear_tt_buffer(struct urb *urb) · line 834

Quoted 3 lines
drivers/usb/core/hub.c +0 -0
              /* FIXME recover somehow ... RESET_TT? */
              return -ENOMEM;
      }

Does the existing memory allocation error message include the &udev->dev device name and driver name? If it doesn't, there will be no way for the user to tell that the error message is related to the device failure.

No, but the effect is similar.

OOM does a dump_stack() so this function's call tree is shown.

#9 lore raw
Quoted 22 lines · Joe Perches
Quoted 2 lines · Alan Stern
Quoted 1 line · SF Markus Elfring

Omit an extra message for a memory allocation failure in this function.

Markus' typical terrible commit message.

Quoted 1 line

drivers/usb/core/hub.c

Quoted 1 line
drivers/usb/core/hub.c +0 -0

[]

Quoted 5 lines
Quoted 5 lines
drivers/usb/core/hub.c +0 -1
@@ -829,7 +829,6 @@ int usb_hub_clear_tt_buffer(struct urb *urb)
       */
      clear = kmalloc(sizeof *clear, GFP_ATOMIC);
      if (clear = NULL) {
-             dev_err(&udev->dev, "can't save CLEAR_TT_BUFFER state\n");
Quoted 8 lines

drivers/usb/core/hub.c int usb_hub_clear_tt_buffer(struct urb *urb) · line 834

Quoted 3 lines
drivers/usb/core/hub.c +0 -0
              /* FIXME recover somehow ... RESET_TT? */
              return -ENOMEM;
      }

Does the existing memory allocation error message include the &udev->dev device name and driver name? If it doesn't, there will be no way for the user to tell that the error message is related to the device failure.

Quoted 3 lines

No, but the effect is similar.

OOM does a dump_stack() so this function's call tree is shown.

A call stack doesn't tell you which device was being handled.

Alan Stern

#10 lore raw
Quoted 10 lines
Quoted 8 lines
Quoted 4 lines

Does the existing memory allocation error message include the &udev->dev device name and driver name? If it doesn't, there will be no way for the user to tell that the error message is related to the device failure.

No, but the effect is similar.

OOM does a dump_stack() so this function's call tree is shown.

A call stack doesn't tell you which device was being handled.

Do you find a default Linux allocation failure report insufficient then?

Would you like to to achieve that the requested information can be determined from a backtrace?

Regards,
Markus

#11 lore raw
Quoted 7 lines · SF Markus Elfring
Quoted 7 lines
Quoted 7 lines
Quoted 4 lines

Does the existing memory allocation error message include the &udev->dev device name and driver name? If it doesn't, there will be no way for the user to tell that the error message is related to the device failure.

No, but the effect is similar.

Quoted 8 lines
Quoted 3 lines
Quoted 1 line

OOM does a dump_stack() so this function's call tree is shown.

A call stack doesn't tell you which device was being handled.

Do you find a default Linux allocation failure report insufficient then?

Would you like to to achieve that the requested information can be determined from a backtrace?

It is not practical to do this. The memory allocation routines do not for what purpose the memory is being allocated; hence when a failure occurs they cannot tell what device (or other part of the system) will be affected.

That's why we have a secondary error message.

Alan Stern

#12 lore raw

Hi Alan,

Quoted 14 lines · Alan Stern
Quoted 13 lines · SF Markus Elfring
Quoted 10 lines
Quoted 8 lines
Quoted 4 lines

Does the existing memory allocation error message include the &udev->dev device name and driver name? If it doesn't, there will be no way for the user to tell that the error message is related to the device failure.

No, but the effect is similar.

OOM does a dump_stack() so this function's call tree is shown.

A call stack doesn't tell you which device was being handled.

Do you find a default Linux allocation failure report insufficient then?

Quoted 7 lines
Quoted 2 lines

Would you like to to achieve that the requested information can be determined from a backtrace?

It is not practical to do this. The memory allocation routines do not for what purpose the memory is being allocated; hence when a failure occurs they cannot tell what device (or other part of the system) will be affected.

If even allocation of 24 bytes fails, lots of other devices and other parts of the system will start failing really soon...

Quoted 1 line

That's why we have a secondary error message.

... and the secondary error message would still be useless.

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

#13 lore raw
Quoted 20 lines · Geert Uytterhoeven

Hi Alan,

Quoted 17 lines · Alan Stern
Quoted 15 lines · SF Markus Elfring
Quoted 10 lines
Quoted 8 lines
Quoted 4 lines

Does the existing memory allocation error message include the &udev->dev device name and driver name? If it doesn't, there will be no way for the user to tell that the error message is related to the device failure.

No, but the effect is similar.

OOM does a dump_stack() so this function's call tree is shown.

A call stack doesn't tell you which device was being handled.

Do you find a default Linux allocation failure report insufficient then?

Would you like to to achieve that the requested information can be determined from a backtrace?

Quoted 8 lines
Quoted 4 lines

It is not practical to do this. The memory allocation routines do not for what purpose the memory is being allocated; hence when a failure occurs they cannot tell what device (or other part of the system) will be affected.

If even allocation of 24 bytes fails, lots of other devices and other parts of the system will start failing really soon...

Small allocations never fail in the current kernel.

regards,
dan carpenter

#14 lore raw

Hi Dan,

Quoted 24 lines · Dan Carpenter
Quoted 23 lines · Geert Uytterhoeven
Quoted 21 lines · Alan Stern
Quoted 7 lines · SF Markus Elfring
Quoted 7 lines
Quoted 7 lines
Quoted 4 lines

Does the existing memory allocation error message include the &udev->dev device name and driver name? If it doesn't, there will be no way for the user to tell that the error message is related to the device failure.

No, but the effect is similar.

Quoted 8 lines
Quoted 3 lines
Quoted 1 line

OOM does a dump_stack() so this function's call tree is shown.

A call stack doesn't tell you which device was being handled.

Do you find a default Linux allocation failure report insufficient then?

Would you like to to achieve that the requested information can be determined from a backtrace?

It is not practical to do this. The memory allocation routines do not for what purpose the memory is being allocated; hence when a failure occurs they cannot tell what device (or other part of the system) will be affected.

Quoted 4 lines
Quoted 2 lines

If even allocation of 24 bytes fails, lots of other devices and other parts of the system will start failing really soon...

Small allocations never fail in the current kernel.

A few comments (this is in response to a patch from Markus, so there have to be lots of questions and uncertainties ;-)
1. In the current kernel. What about the future?
2. If a small allocation cannot fail, what happens if the small memory slab is exhausted? A new page must be allocated, which will trigger an OOM, and some other part of the system will be killed and fail.
3. This driver uses GFP_ATOMIC, is that guaranteed to succeed? I think not.

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

#15 lore raw
Quoted 2 lines · Geert Uytterhoeven

A few comments (this is in response to a patch from Markus, so there have to be lots of questions and uncertainties ;-)

Note, because of the patch author, I'm not applying it no matter what, so this discussion is really going nowhere.

greg k-h

#16 lore raw

Am Donnerstag, den 07.12.2017, 09:56 +0100 schrieb Greg Kroah-Hartman:

Quoted 7 lines · Geert Uytterhoeven
Quoted 3 lines

A few comments (this is in response to a patch from Markus, so there have to be lots of questions and uncertainties ;-)

Note, because of the patch author, I'm not applying it no matter what, so this discussion is really going nowhere.

We really need to come to a consensus on that question.
If those additional messages really are redundant, we could save memory deleting them. Or alternatively, if they are not and we need to know which device is hit, we should centralize that reporting and tell the VM subsystem not the dump a stack trace.

Regards
Oliver

#17 lore raw
In reply to Geert Uytterhoeven
Quoted 6 lines · Geert Uytterhoeven
Quoted 2 lines

Small allocations never fail in the current kernel.

A few comments (this is in response to a patch from Markus, so there have to be lots of questions and uncertainties ;-)
1. In the current kernel. What about the future?

Right. No one can predict. And the small allocations don't fail rule causes some problems.

Quoted 3 lines

2. If a small allocation cannot fail, what happens if the small memory slab is exhausted? A new page must be allocated, which will trigger an OOM, and some other part of the system will be killed and fail.

Right.

Quoted 2 lines

3. This driver uses GFP_ATOMIC, is that guaranteed to succeed? I think not.

Right again. I was missing the first email in the thread because of my email filters so I didn't see this was atomic.

regards,
dan carpenter

#18 lore raw
In reply to Geert Uytterhoeven
Quoted 20 lines · Geert Uytterhoeven

Hi Alan,

Quoted 17 lines · Alan Stern
Quoted 15 lines · SF Markus Elfring
Quoted 10 lines
Quoted 8 lines
Quoted 4 lines

Does the existing memory allocation error message include the &udev->dev device name and driver name? If it doesn't, there will be no way for the user to tell that the error message is related to the device failure.

No, but the effect is similar.

OOM does a dump_stack() so this function's call tree is shown.

A call stack doesn't tell you which device was being handled.

Do you find a default Linux allocation failure report insufficient then?

Would you like to to achieve that the requested information can be determined from a backtrace?

Quoted 7 lines
Quoted 4 lines

It is not practical to do this. The memory allocation routines do not for what purpose the memory is being allocated; hence when a failure occurs they cannot tell what device (or other part of the system) will be affected.

If even allocation of 24 bytes fails, lots of other devices and other parts of the system will start failing really soon...

In fact, one wonders if the allocation routine's own error message and stack trace would actually appear anywhere...

Quoted 3 lines
Quoted 1 line

That's why we have a secondary error message.

... and the secondary error message would still be useless.

Well, there is still a difference between GFP_ATOMIC and GFP_KERNEL allocations. Failure of the first doesn't necessarily imply failure of the second, so perhaps the system could recover.

The real problem is that the kernel development community doesn't have a fixed policy on how to handle memory allocation errors. There are several possibilities:

Ignore them on the grounds that they will never happen. (Really? And what is the size limit above which they might happen?)

Ignore them on the grounds that the machine will hang or crash in the near future. (Is this guaranteed?)

Treat them like other errors: try to press forward (perhaps in a degraded mode).

Treat them like other errors: log an error message and try to press forward.

And probably a few more that haven't occurred to me. No doubt there are examples of each at various places in the kernel. Nobody seems able to agree on a single course of action. Maybe not even Linus.

If there was one agreed-upon policy, then we could definitively point to old code and say "That's wrong, and here is how it should be fixed." But currently this is not possible, and we end up with repetitive discussions like this one that aren't of general use.

Alan Stern

#19 lore raw
Quoted 2 lines · Alan Stern

The real problem is that the kernel development community doesn't have a fixed policy on how to handle memory allocation errors.

[]

Quoted 4 lines

If there was one agreed-upon policy, then we could definitively point to old code and say "That's wrong, and here is how it should be fixed." But currently this is not possible, and we end up with repetitive discussions like this one that aren't of general use.

Well stated.

My preferred policy would be to remove all the individual allocation failure messages and only use the generic warn_alloc()/dump_stack() mechanism.

#20 lore raw
In reply to Alan Stern
Quoted 8 lines · Alan Stern

The real problem is that the kernel development community doesn't have a fixed policy on how to handle memory allocation errors. There are several possibilities:

Ignore them on the grounds that they will never happen. (Really? And what is the size limit above which they might happen?)

It's pretty rare to ignore allocation failures these days. It causes static checker warnings.

Sometimes it's accepted for people to ignore errors during boot but I hate that because how am I supposed to filter out those static checker warnings? It's better to pretend that the kernel will still boot without essential hardware instead of wasting everyone's time who looks at checker output.

Quoted 2 lines

Ignore them on the grounds that the machine will hang or crash in the near future. (Is this guaranteed?)

On boot sometimes yes.

Quoted 7 lines

Treat them like other errors: try to press forward (perhaps in a degraded mode).

Treat them like other errors: log an error message and try to press forward.

The standard is to treat them like errors and try press forward in a degraded mode but don't print a message. Checkpatch.pl complains if you print a warning for allocation failures. A lot of low level functions handle their own messages pretty well but especially kmalloc() does.

I also have a special static checker warning for when people do:

	foo = alloc();
	BUG_ON(!foo);

People do that occasionally but fortunately it's pretty rare. 10 years ago that's how btrfs did error handling, but now there are only 4 of these still remaining in btrfs.

regards,
dan carpenter

#21 lore raw
Quoted 28 lines · Dan Carpenter
Quoted 8 lines · Alan Stern

The real problem is that the kernel development community doesn't have a fixed policy on how to handle memory allocation errors. There are several possibilities:

Ignore them on the grounds that they will never happen. (Really? And what is the size limit above which they might happen?)

It's pretty rare to ignore allocation failures these days. It causes static checker warnings.

Sometimes it's accepted for people to ignore errors during boot but I hate that because how am I supposed to filter out those static checker warnings? It's better to pretend that the kernel will still boot without essential hardware instead of wasting everyone's time who looks at checker output.

Quoted 2 lines

Ignore them on the grounds that the machine will hang or crash in the near future. (Is this guaranteed?)

On boot sometimes yes.

Quoted 4 lines

Treat them like other errors: try to press forward (perhaps in a degraded mode).

Quoted 8 lines
Quoted 3 lines

Treat them like other errors: log an error message and try to press forward.

The standard is to treat them like errors and try press forward in a degraded mode but don't print a message. Checkpatch.pl complains if you print a warning for allocation failures. A lot of low level functions handle their own messages pretty well but especially kmalloc() does.

Which brings us back to my original objection. If an allocation failure has localized effects, but the low-level warning is unable to specify what will be affected, how is the user supposed to connect the effect to the cause?

Alan Stern

Quoted 15 lines

I also have a special static checker warning for when people do:

	foo = alloc();
	BUG_ON(!foo);

People do that occasionally but fortunately it's pretty rare. 10 years ago that's how btrfs did error handling, but now there are only 4 of these still remaining in btrfs.

regards,
dan carpenter

#22 lore raw

Hi Alan,

Quoted 10 lines · Alan Stern
Quoted 4 lines · Dan Carpenter

The standard is to treat them like errors and try press forward in a degraded mode but don't print a message. Checkpatch.pl complains if you print a warning for allocation failures. A lot of low level functions handle their own messages pretty well but especially kmalloc() does.

Which brings us back to my original objection. If an allocation failure has localized effects, but the low-level warning is unable to specify what will be affected, how is the user supposed to connect the effect to the cause?

The backtrace would include usb_hub_clear_tt_buffer, so the user will know USB is affected.
Note that the cause of the memory exhaustion is usually not the caller. Unless it requests a real big block of memory, in which case that will be mentioned in the backtrace, too.

In this particular case, the driver uses GFP_ATOMIC, so allocation failures aren't that rare, and I think the driver should be prepared for that, and try to recover gracefully.

The comment

                /* FIXME recover somehow ... RESET_TT? */

makes me think it isn't.

As this is a pretty small allocation, perhaps it can be done beforehand, without GFP_ATOMIC?

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

#23 lore raw
Quoted 24 lines · Geert Uytterhoeven

Hi Alan,

Quoted 10 lines · Alan Stern
Quoted 4 lines · Dan Carpenter

The standard is to treat them like errors and try press forward in a degraded mode but don't print a message. Checkpatch.pl complains if you print a warning for allocation failures. A lot of low level functions handle their own messages pretty well but especially kmalloc() does.

Which brings us back to my original objection. If an allocation failure has localized effects, but the low-level warning is unable to specify what will be affected, how is the user supposed to connect the effect to the cause?

The backtrace would include usb_hub_clear_tt_buffer, so the user will know USB is affected.
Note that the cause of the memory exhaustion is usually not the caller. Unless it requests a real big block of memory, in which case that will be mentioned in the backtrace, too.

In this particular case, the driver uses GFP_ATOMIC, so allocation failures aren't that rare, and I think the driver should be prepared for that, and try to recover gracefully.

Quoted 8 lines

The comment

                /* FIXME recover somehow ... RESET_TT? */

makes me think it isn't.

As this is a pretty small allocation, perhaps it can be done beforehand, without GFP_ATOMIC?

I can't see how to make that work. We don't know beforehand how many structures will be needed at any time.

Alan Stern

#24 lore raw
In reply to Alan Stern
Quoted 10 lines
Quoted 8 lines
Quoted 3 lines
Quoted 1 line

OOM does a dump_stack() so this function's call tree is shown.

A call stack doesn't tell you which device was being handled.

Do you find a default Linux allocation failure report insufficient then?

Would you like to to achieve that the requested information can be determined from a backtrace?

It is not practical to do this.

I imagine that this depends on details if a backtrace could eventually be configured for your specific needs.

Quoted 2 lines

The memory allocation routines do not for what purpose the memory is being allocated;

Do you want an improved accounting for these purposes?

Quoted 2 lines

hence when a failure occurs they cannot tell what device (or other part of the system) will be affected.

I know that other programs can provide dumps for function call stacks where the parameters which were passed in previous calls could be decoded to some degree.

Quoted 1 line

That's why we have a secondary error message.

I am curious on how the relevance of such messages will be interpreted by other developers in this software area.

Regards,
Markus