From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751711AbbJ2OvA (ORCPT ); Thu, 29 Oct 2015 10:51:00 -0400 Received: from smtprelay0147.hostedemail.com ([216.40.44.147]:35564 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751017AbbJ2Ou6 (ORCPT ); Thu, 29 Oct 2015 10:50:58 -0400 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::::,RULES_HIT:41:355:379:541:599:800:960:966:968:973:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1542:1593:1594:1711:1730:1747:1777:1792:2194:2196:2199:2200:2393:2553:2559:2562:2828:2898:3138:3139:3140:3141:3142:3353:3622:3865:3868:3871:3873:4321:4385:4605:5007:6261:7514:9010:10004:10400:10848:11026:11232:11658:11914:12043:12296:12517:12519:12679:12740:13019:13255:13972:14096:14097:21080:30012:30054:30070:30090:30091,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:2,LUA_SUMMARY:none X-HE-Tag: crate50_2548c2010d44a X-Filterd-Recvd-Size: 3026 Message-ID: <1446130255.2757.168.camel@perches.com> Subject: Re: [PATCH v3] um: net: replace GFP_KERNEL with GFP_ATOMIC when spinlock is held From: Joe Perches To: Saurabh Sengar Cc: jdike@addtoit.com, richard@nod.at, user-mode-linux-devel@lists.sourceforge.net, user-mode-linux-user@lists.sourceforge.net, linux-kernel@vger.kernel.org Date: Thu, 29 Oct 2015 07:50:55 -0700 In-Reply-To: <1446110203-21968-1-git-send-email-saurabh.truth@gmail.com> References: <1446110203-21968-1-git-send-email-saurabh.truth@gmail.com> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.12.11-0ubuntu3 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 2015-10-29 at 14:46 +0530, Saurabh Sengar wrote: > replace GFP_KERNEL with GFP_ATOMIC while spinlock is held, > as code while holding a spinlock should be atomic. > GFP_KERNEL may sleep and can cause deadlock, > where as GFP_ATOMIC may fail but certainly avoids deadlock > > Signed-off-by: Saurabh Sengar > --- > v3: removed the atomic variable, as per Richard comment Trivia: You could remove the gfp_mask variables too and just use GFP_KERNEL and GFP_ATOMIC directly. > diff --git a/arch/um/drivers/net_kern.c b/arch/um/drivers/net_kern.c [] > @@ -600,20 +600,22 @@ void register_transport(struct transport *new) > void *init; > char *mac = NULL; > int match; > + int gfp_mask; > > spin_lock(&transports_lock); > BUG_ON(!list_empty(&new->list)); > list_add(&new->list, &transports); > spin_unlock(&transports_lock); > > + gfp_mask = GFP_KERNEL; > list_for_each_safe(ele, next, ð_cmd_line) { > eth = list_entry(ele, struct eth_init, list); > match = check_transport(new, eth->init, eth->index, &init, > - &mac); > + &mac, gfp_mask); > if (!match) > continue; > else if (init != NULL) { > - eth_configure(eth->index, init, mac, new); > + eth_configure(eth->index, init, mac, new, gfp_mask); > kfree(init); > } > list_del(ð->list); > @@ -627,14 +629,17 @@ static int eth_setup_common(char *str, int index) > void *init; > char *mac = NULL; > int found = 0; > + int gfp_mask; > > spin_lock(&transports_lock); > + gfp_mask = GFP_ATOMIC; > list_for_each(ele, &transports) { > transport = list_entry(ele, struct transport, list); > - if (!check_transport(transport, str, index, &init, &mac)) > + if (!check_transport(transport, str, index, &init, > + &mac, gfp_mask)) > continue; > if (init != NULL) { > - eth_configure(index, init, mac, transport); > + eth_configure(index, init, mac, transport, gfp_mask); > kfree(init); > } > found = 1;