From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752678AbdLPIPk (ORCPT ); Sat, 16 Dec 2017 03:15:40 -0500 Received: from mail-io0-f195.google.com ([209.85.223.195]:42185 "EHLO mail-io0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752220AbdLPIPg (ORCPT ); Sat, 16 Dec 2017 03:15:36 -0500 X-Google-Smtp-Source: ACJfBovBh0W8KJXu4nQpkFa+blKqJ0K+EcV31xrmq3TnufIAKDYUzgHsTs4DWu8kDEl5M7JezFhwAw== From: shrikant Subject: Re: [PATCH] drivers: base: power: Fix GFP_KERNEL in spinlock context To: Pavel Machek , Geert Uytterhoeven Cc: "Rafael J. Wysocki" , Len Brown , Greg KH , Linux PM list , "linux-kernel@vger.kernel.org" , Suniel Mahesh , Karthik Tummala , raghu@techveda.org References: <1513086342-3581-1-git-send-email-shrikant.maurya@techveda.org> <20171215084515.GB8221@amd> Message-ID: Date: Sat, 16 Dec 2017 13:45:31 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: <20171215084515.GB8221@amd> Content-Type: text/plain; charset=windows-1252 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Friday 15 December 2017 02:15 PM, Pavel Machek wrote: > On Tue 2017-12-12 15:58:00, Geert Uytterhoeven wrote: >> Hi Shrikant, >> >> On Tue, Dec 12, 2017 at 2:45 PM, wrote: >>> From: Shrikant Maurya >>> >>> As reported by Jia-Ju Bai (https://lkml.org/lkml/2017/12/11/872): >>> API's are using GFP_KERNEL to allocate memory which may sleep. >>> >>> To ensure atomicity such allocations must be avoided in critical >>> sections under spinlock. >>> Fixed by replacing GFP_KERNEL to GFP_ATOMIC. >>> >>> Reported-by: Jia-Ju Bai >>> Signed-off-by: Shrikant Maurya >>> Signed-off-by: Suniel Mahesh >>> Signed-off-by: Raghu Bharadwaj >>> Signed-off-by: Karthik Tummala >> >> Can't the call to device_init_wakeup() in isp116x_start() just be moved >> below the spinlock release? >> >>> --- a/drivers/base/power/wakeup.c >>> +++ b/drivers/base/power/wakeup.c >>> @@ -92,11 +92,11 @@ struct wakeup_source *wakeup_source_create(const char *name) >>> { >>> struct wakeup_source *ws; >>> >>> - ws = kmalloc(sizeof(*ws), GFP_KERNEL); >>> + ws = kmalloc(sizeof(*ws), GFP_ATOMIC); >> >> With GFP_ATOMIC, allocation failure is much more likely to occur. >> So IMHO it's better to fix the isp116x, than to impose this burden on >> every user. >> >>> if (!ws) >>> return NULL; >>> >>> - wakeup_source_prepare(ws, name ? kstrdup_const(name, GFP_KERNEL) : NULL); >>> + wakeup_source_prepare(ws, name ? kstrdup_const(name, GFP_ATOMIC) : NULL); >>> return ws; > > NAK. This will silently replace name with NULL if memory is low. Yes, replacing GFP_KERNEL with GFP_ATOMIC in both places will cause more issues than it fixes. > > Pavel > Thank you Pavel. -- Shrikant techveda.org