Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp683002ybi; Fri, 2 Aug 2019 02:33:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqwdGtEA1jl/DKOasyoPxog4QxqMwtkLlrzmiARxEPcaeqrY4M0OoAts2WvalHOnexPhaq5d X-Received: by 2002:a63:7a01:: with SMTP id v1mr126202589pgc.310.1564738393383; Fri, 02 Aug 2019 02:33:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564738393; cv=none; d=google.com; s=arc-20160816; b=qQAeT/+k+oK4tiKzg23QWOaE7RL3w9u9QrIiuZMHx4qVDrfTpwqvNshw5ovJaLwVOM SyhXsDBOygSaY3PIR0vUe1rsM0kAUW6c5Bkp+zCLfskdgJtgOoe2Ak78e/fwWCWkEyaC wU91sjcxuSHWMH6EXC4MVGDZ2ljJl9aoIo15ZnDeUSg09ocS/JE/p6HIh60M9E9VljFf 8KvUwRHePYndl6L8kum8Nqu5t3VXdNenhcZGn16wgoTxqC46fmo0n80XPI5duBXFKb4y pa0hlyE9IbV4/czZXWLZ4FsfwCcYP0ZvTzMOwpbIJ0Ie3eG8q+wJrOmhGxURKv6XBUEY Z7qQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=xIS84dOSAz5Zi5IwNNjc/4HDfUWXTiAuOWWFMLbZ37w=; b=QThD2Dbqv2oAwgwBiSxEj+8FoZ9ID7G3yrNOXVqhfcIMz2hBiSbrnUWP+LP6JmG7SP rRF95vUQA7Z5eUljCFZ11jq/4dMb6xB4J1+Um6nGHoJcpGmVygOvtiOIuipMFd+GiLPl yfIk4UEsM2g/tGQhUDUVIO4khuDcoW1/QiU4yOHKQVxz8apYq7FrbpoTjBsqTNFAMAr6 Y7Jfbbq2rmUBaCSb16MRDzoj3H0F6nQ1S7TPThNV5K2lHW/uTONwIXDDl2RBpaRtgPw/ Z/7oN1Fk8yijIU4h18g9dqRBl5mrVVtDR2Wdf+1ybTzPTu/JXVQwlWmN/VGZuMaDZeBO fDkQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b92si6409974pjc.17.2019.08.02.02.32.57; Fri, 02 Aug 2019 02:33:13 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390423AbfHBHvg (ORCPT + 99 others); Fri, 2 Aug 2019 03:51:36 -0400 Received: from smtp10.smtpout.orange.fr ([80.12.242.132]:50242 "EHLO smtp.smtpout.orange.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729283AbfHBHvg (ORCPT ); Fri, 2 Aug 2019 03:51:36 -0400 Received: from [192.168.1.109] ([176.167.178.124]) by mwinf5d45 with ME id k7rX2000A2hRaC0037rXnD; Fri, 02 Aug 2019 09:51:32 +0200 X-ME-Helo: [192.168.1.109] X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Fri, 02 Aug 2019 09:51:32 +0200 X-ME-IP: 176.167.178.124 Subject: Re: [PATCH] HID: usbhid: Use GFP_KERNEL instead of GFP_ATOMIC when applicable To: wharms@bfs.de Cc: jikos@kernel.org, benjamin.tissoires@redhat.com, linux-usb@vger.kernel.org, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org References: <20190801074759.32738-1-christophe.jaillet@wanadoo.fr> <5D42B98B.40900@bfs.de> From: Christophe JAILLET Message-ID: <36fe1980-9b92-084d-f9db-fac07e624076@wanadoo.fr> Date: Fri, 2 Aug 2019 09:51:25 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <5D42B98B.40900@bfs.de> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, (and sorry if you receive this email twice. I've used a web mail which sends HTML by default and it was rejected by ML) Le 01/08/2019 à 12:06, walter harms a écrit : > > > Am 01.08.2019 09:47, schrieb Christophe JAILLET: >> There is no need to use GFP_ATOMIC when calling 'usb_alloc_coherent()' >> here. These calls are done from probe functions and using GFP_KERNEL should >> be safe. >> The memory itself is used within some interrupts, but it is not a >> problem, once it has been allocated. >> >> Signed-off-by: Christophe JAILLET >> --- >> drivers/hid/usbhid/usbkbd.c | 4 ++-- >> drivers/hid/usbhid/usbmouse.c | 2 +- >> 2 files changed, 3 insertions(+), 3 deletions(-) >> >> diff --git a/drivers/hid/usbhid/usbkbd.c b/drivers/hid/usbhid/usbkbd.c >> index d5b7a696a68c..63e8ef8beb45 100644 >> --- a/drivers/hid/usbhid/usbkbd.c >> +++ b/drivers/hid/usbhid/usbkbd.c >> @@ -239,11 +239,11 @@ static int usb_kbd_alloc_mem(struct usb_device *dev, struct usb_kbd *kbd) >> return -1; >> if (!(kbd->led = usb_alloc_urb(0, GFP_KERNEL))) >> return -1; >> - if (!(kbd->new = usb_alloc_coherent(dev, 8, GFP_ATOMIC, &kbd->new_dma))) >> + if (!(kbd->new = usb_alloc_coherent(dev, 8, GFP_KERNEL, &kbd->new_dma))) >> return -1; >> if (!(kbd->cr = kmalloc(sizeof(struct usb_ctrlrequest), GFP_KERNEL))) >> return -1; >> - if (!(kbd->leds = usb_alloc_coherent(dev, 1, GFP_ATOMIC, &kbd->leds_dma))) >> + if (!(kbd->leds = usb_alloc_coherent(dev, 1, GFP_KERNEL, &kbd->leds_dma))) >> return -1; >> > > the kernel style is usually: > kbd->new = usb_alloc_coherent(dev, 8, GFP_ATOMIC, &kbd->new_dma); > if (!kbd->new) > return -1; > Searching with coccinelle with: * x = usb_alloc_coherent(..., <+... GFP_KERNEL ...+>, ...); finds 67 files, whereas: * x = usb_alloc_coherent(..., <+... GFP_ATOMIC ...+>, ...); only finds 11 files. > > in usbmouse.c this is done, any reason for the change here ? > No real reason in fact, just to be consistent with surrounding code. Unless some allocations are done within a spin_lock/spin_unlock, using both GFP_KERNEL and GFP_ATOMIC in the same function looks spurious to me. Either there is a bug (GFP_KERNEL should be GFP_ATOMIC), or a useless constraint is given to the memory allocator. CJ > re, > wh > >> return 0; >> diff --git a/drivers/hid/usbhid/usbmouse.c b/drivers/hid/usbhid/usbmouse.c >> index 073127e65ac1..c89332017d5d 100644 >> --- a/drivers/hid/usbhid/usbmouse.c >> +++ b/drivers/hid/usbhid/usbmouse.c >> @@ -130,7 +130,7 @@ static int usb_mouse_probe(struct usb_interface *intf, const struct usb_device_i >> if (!mouse || !input_dev) >> goto fail1; >> >> - mouse->data = usb_alloc_coherent(dev, 8, GFP_ATOMIC, &mouse->data_dma); >> + mouse->data = usb_alloc_coherent(dev, 8, GFP_KERNEL, &mouse->data_dma); >> if (!mouse->data) >> goto fail1; >> >