Project

General

Profile

Actions

Feature #3232

open

043: Using a blocking memory allocation when spinlock is held

Added by Evgeny Novikov almost 12 years ago. Updated over 9 years ago.

Status:
Open
Priority:
Normal
Assignee:
Start date:
07/19/2012
Due date:
% Done:

0%

Estimated time:
Published in build:

Description

(copied almost as is from kernel-rules/rules/DRVRULES_en.trl)

Summary

You should use GFP_ATOMIC flag when calling memory allocation functions when spinlock is held.

Description

A sleeping memory allocations should be forbidden when spinlock is held. Sleeping memory allocation may cause context switch to the other process if the allocation system (e.g. SLAB) can't allocate memory right now. This erroneous behavior can result in:
  • General decrease of system productivity. The other system processes (including real-time processes) that use locked resource will depend on memory allocation.
  • OS corruption in embedded systems (those without MMU and address pages), because an implicit deadlock happens if memory allocation is impossible at the moment.

Therefore, having a spinlock acquired, you should use GFP_ATOMIC flag when calling memory allocation functions, such as `kmalloc`, `vmalloc`, `get_free_pages` etc.

Links

Sample bugfix in drivers/net/wireless/orinoco/wext.c


Related issues 1 (0 open1 closed)

Related to C Instrumentation Framework - Feature #3802: Add ability to refer to function argument by its name specified in aspect fileClosedEvgeny Novikov12/14/2012

Actions
Actions

Also available in: Atom PDF