Skip to contentSkip to conversation

drm: i915_gem_inactive_scan: insufficient nr_to_scan size

PATCH In review Artem Savkov 1 participant 2 messages Jul 23, 2013

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

PATCH 1/1 drm: i915_gem_inactive_scan: insufficient nr_to_scan size

nr_to_scan needs to be (unsigned) long, not int, otherwise we get negative values on 32bit systems during shrink resulting in lots of messages like one below.

[ 4078.989603] shrink_slab: i915_gem_inactive_scan+0x0/0xc0 negative objects to delete nr=-289580136

Introduced in "drivers: convert shrinkers to new count/scan API" (383e4f4a4cdeb2dd552e90811089bcb4d41eb32e in linux-next.git)

---
 drivers/gpu/drm/i915/i915_gem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_gem.c +1 -1
index 4635354..b3b4891b 100644
@@ -4649,7 +4649,7 @@ i915_gem_inactive_scan(struct shrinker *shrinker, struct shrink_control *sc)
 			     struct drm_i915_private,
 			     mm.inactive_shrinker);
 	struct drm_device *dev = dev_priv->dev;
-	int nr_to_scan = sc->nr_to_scan;
+	unsigned long nr_to_scan = sc->nr_to_scan;
 	unsigned long freed;
 	bool unlock = true;
 
Signature · 1 line
1.8.3.3
#1 lore raw
Quoted 8 lines · Artem Savkov

nr_to_scan needs to be (unsigned) long, not int, otherwise we get negative values on 32bit systems during shrink resulting in lots of messages like one below.

[ 4078.989603] shrink_slab: i915_gem_inactive_scan+0x0/0xc0 negative objects to delete nr=-289580136

Introduced in "drivers: convert shrinkers to new count/scan API" (383e4f4a4cdeb2dd552e90811089bcb4d41eb32e in linux-next.git)

Sorry, looks like my analysis was wrong, I can still see the issue with this patch.

Signature · 2 lines
Regards,
Artem