Saturday, August 20, 2016

Linux: Sleeping while atomic during kmalloc solved

So you ran into a crash where the kernel complains that you were sleeping while atomic.
You were either able to run objdump or gdb and track down that the crash is caused due
to a kmalloc? How is that possible?
Did you make recent changes which included putting in a kmalloc?

Typical format:
The function is declared in <linux/slab.h>:
void * kmalloc(size_t size, int flags)

This function is often used in a similar fashion:
struct packet_st *ptr;
ptr = kmalloc(sizeof(struct packet_st), GFP_KERNEL);
if (!ptr)
        /* handle error ... */

The problem is that the GFP_KERNEL has to be used in proper context. i.e. you cannot use GFP_KERNEL from IRQ context. This is because GFP_KERNEL tells the kernel that if it was not able to immediately allocate the required page, it is free to sleep. However, as we know, we are not allowed to sleep in "atomic" context. 

Hence, we need to make sure that appropriate context flag is used while requesting memory. If you are in the IRQ context, it is useful to use the GFP_ATOMIC flag instead of GFP_KERNEL. This will solve the problem of the crash.


15 comments:

sports online said...

UFC 210
Watch UFC 210
UFC 210 Live
UFC 210 Fight Card
UFC 210 Main Card
UFC 210 Free


UFC 210 Live
UFC 210 Live Stream
UFC 210 Live Online

Mailey Sirus 2 said...

24's Aljamain Sterling: I let fans, media coordinate style in 2 Profoundly Cited-MMAjunkie.com-19 hours earlier. Dana White: McGregor versus Mayweather is 'one and done,' no more. All the talk about UFC lightweight champion Conor McGregor going up against multi-time champion Floyd Mayweather has stirred up a couple of other.
UFC 210
UFC 210 Live , UFC 210 Fight Card , UFC 210 Fight , UFC 210 Card , UFC 210 Live Stream , UFC 210 PPV



"Disorder" Miller admits to around dozen. The past UFC middleweight yielded to just about twelve legal offenses and wrongdoings beginning from various clashes with police over. UFC on FOX 24: Aljamain Sterling let fans and media play into his. Sterling will want to end his slide when he goes up against Augusto Mendes at UFC on FOX 24 on April 15 in Kansas City, Mo. Additionally, you can trust.
UFC 210
UFC 210 Live , UFC 210 Fight Card , UFC 210 Fight , UFC 210 Card , UFC 210 Live Stream , UFC 210 PPV

David E. Alexander said...

Kentucky Derby 2017
Watch Kentucky Derby 2017
2017 Kentucky Derby
Kentucky Derby

Kentucky Derby 2017 Live
Canelo vs Chavez
Canelo vs Chavez jr
Alvarez vs Chavez
Monster Energy Supercross Finals 2017

David E. Alexander said...

Mtv movie awards 2017
Mtv movie awards
Mtv movie and tv awards 2017 Nominees
Mtv movie awards 2017 Live
MTV Movie And TV Awards 2017
Watch Mtv movie awards 2017
Mtv movie awards Online

nd nasif adnan said...

The 28-year-old UFC star moved before Mayweather as their press visit commenced in Los Angeles in front of the August 26 session in Las Vegas which will see McGregor in his first expert boxing battle against five-weight undefeated champion Mayweather vs Mcgregor

ptman said...


Mayweather vs McGregor
McGregor vs Mayweather
Mayweather vs McGregor Live
McGregor vs Mayweather Live
McGregor vs Mayweather Live Stream

Conor McGregor vs Floyd Mayweather
Floyd Mayweather vs Conor McGregor
Floyd Mayweather vs Conor McGregor Live
Conor McGregor vs Floyd Mayweather Live

Devid Marsh said...

College Football Bowl
College Football Bowl 2018
NCAA Football Bowl 2018
College Football Bowl Games 2018
College Football Bowl Live
College Football Bowl Live Stream
Watch College Football Bowl Live
Watch College Football Bowl Live Stream
College Football Bowl 2018 Live
College Football Bowl 2018 Live Stream
Watch College Football Bowl 2018 Live
Watch College Football Bowl 2018 Live Stream
College Football Bowl Games Live
College Football Bowl Games Live Stream
Watch Football Bowl Games Live
Watch College Football Bowl Games Live Stream
College Football Bowl Game 2018 Live
College Football Bowl Game 2018 Live Stream

NFL Playoffs
NFL Playoffs 2018
NFL Playoff Games 2018
NFL Playoffs Live
NFL Playoffs Live Stream
Watch NFL Playoffs Live
Watch NFL Playoffs Live Stream
NFL Playoffs 2018 Live
NFL Playoffs 2018 Live Stream
Watch NFL Playoffs 2018 Live
Watch NFL Playoffs 2018 Live Stream
NFL Playoff Games Live
NFL Playoff Games Live Stream
Watch NFL Playoff Games Live Stream
NFL Playoffs Game 2018 Live
NFL Playoffs Game 2018 Live Stream

Super Bowl 2018 said...

Watch Super Bowl 2018 Live Stream HD Online Here:

Super Bowl 2018
Super Bowl 2018 Tickets
Super Bowl Tickets
Super Bowl 2018 Live
Super Bowl 2018 Live Stream
Super Bowl 52
Super Bowl 52 Tickets
Super Bowl 52 Live
Super Bowl 52 Live Stream
Super Bowl LII
Super Bowl LII Tickets
Super Bowl LII Live
Super Bowl LII Live Stream

Winter Olympics said...

Watch Winter Olympics 2018 Live Stream HD Online Here:

Winter Olympics 2018
Winter Olympics 2018 Live
Winter Olympics 2018 Live Stream

Elton John Tour 2018 said...

Buy Elton John Tour 2018 Best Tickets Here:

Elton John Tour
Elton John Tour 2018
Elton John Tour Tickets
Elton John Tour 2018 Tickets

Elton John Tour 2018 said...

Elton John Tour
Elton John Tour 2018
Genesis Open
Genesis Open 2018

Khan Roni said...

Watch Daytona 500 Live Stream HD Online Here:

Daytona 500
Daytona 500
Daytona 500
Daytona 500
Daytona 500
Daytona 500
Daytona 500
Daytona 500
Daytona 500
Daytona 500
Daytona 500
Daytona 500
Daytona 500
Daytona 500

D2 Bet said...

The 28-year-old UFC star moved before Mayweather as their press visit commenced in Los Angeles in front of the August 26 session in Las Vegas


สมัคร D2BET

miss mem said...

Father's day 2018
Father's day
Fathers day Gifts
Fathers day T shirts
Fathers day T shirt
Fathers day 2018 gifts idea
Fathers day 2018 gifts
Fathers day 2018 T shirts
Fathers day 2018 gift
Fathers day gifts idea
Fathers day 2018 T shirt

Unknown said...

TCU Football
TCU Horned Frogs

USC Football
USC Trojans

Michigan State Football
Michigan State Spartans

UCF Football
UCF Knights

Penn State Football
Penn State Nittany Lions

Stanford Football
Stanford Cardinal

Ole Miss Football
Ole Miss Rebels

Wisconsin Football
Wisconsin Badgers

Post a Comment