Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1025972yba; Thu, 4 Apr 2019 02:43:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqzcqSM5pEAQg9TqXXx+wmvG2i+/pDN41iAQqa3iA6wrvz/EihUK28CLG/xZZk/m9PwXeK4V X-Received: by 2002:a17:902:2848:: with SMTP id e66mr5287740plb.181.1554370991962; Thu, 04 Apr 2019 02:43:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554370991; cv=none; d=google.com; s=arc-20160816; b=flFVTWJXI3GM8c73yigz1I2J6IEj6ZB1nC2Pmq80owltN01lyd3ZzxaMQd0F9ua/JY o2Wm/3HUKHo6cnYoF8ruF74bhy15fS0C+bNEsBRoiFuBHKIUd6tGqSMviepI9JFB0m+c 9tvmmGfWHukKHBzOEfQ71FRWIwSjNcIq2Zw6s8a8B50WOKgn6jVeNvDnZ0eFAKIl2DIN frWVTPDMTC/1V7uZ6SLjaMfiPXLWxRpBUzYRCaWgcxHlfUANWYMOVtg4w4LJrlY9kbwM s+SVVSDno89GM+KXkhdub7IziOomFOA7nSXrMIrscWLQbeBtsWd9lXmZcIhw4os91rNi 2GfQ== 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:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=VnHULHrXJARJeYHJ/HTP79cLf4NMi0WFGA9F8EkBEZc=; b=ZnzsCcxP7Q8mrTuB2BWYaBjWqiuZSbAcjAMh4YwfB7KlAphfHZYmR7yHJkp8/h2/vR WVJq9NgREpTWMX0+mHxewc3rIkVGghhdXpUZJTlUUKJjVXTkNEiOez5KJ/xuXNIZZlhg po5W4zHVODenjfg8XKmMXwvPCr17wV5YZKbAM424s1uH1g/IcGgw0fT9D+jZCYm5b1eZ XhVr1fNltjSXm7qGMj76sRw0w880CLkyEBFcS88VcaR5+FxhD96q0ukhUDQTkjWDoPyR eq6UaWSQo6jEbj5mDwk/8npafgoeARbj3HLJPBeGmrjTPhylXJGDyQ6SYaa/u5XYxjFq 9hVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=fzn30nKI; 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 w12si2883708plz.67.2019.04.04.02.42.56; Thu, 04 Apr 2019 02:43:11 -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; dkim=pass header.i=@kernel.org header.s=default header.b=fzn30nKI; 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 S1731237AbfDDJmN (ORCPT + 99 others); Thu, 4 Apr 2019 05:42:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:38854 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731004AbfDDJBk (ORCPT ); Thu, 4 Apr 2019 05:01:40 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6E18C2147C; Thu, 4 Apr 2019 09:01:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1554368498; bh=hXrA8yftS/eVEcPPJEpdPvvuR8j+ShkP6G0SDEm7Uuw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fzn30nKIXhKrP0kYqSTAn3CcZxyTvGPLPEGrXvxQs3vQuJzS2Dq+mvMC56ihcvHRn t+354jSDXkh7exXZs4TGMzIUbsReoFK/pazi0+QxeoGTU7FjUD2XwwVgyJf0fsUaVK tchzdiWQXwT6z1MAqh9vbpdyfR+HTHwNEYyJSAMQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Benjamin Block , Bart Van Assche , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 4.19 054/187] scsi: core: replace GFP_ATOMIC with GFP_KERNEL in scsi_scan.c Date: Thu, 4 Apr 2019 10:46:31 +0200 Message-Id: <20190404084605.633236057@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190404084603.119654039@linuxfoundation.org> References: <20190404084603.119654039@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit 1749ef00f7312679f76d5e9104c5d1e22a829038 ] We had a test-report where, under memory pressure, adding LUNs to the systems would fail (the tests add LUNs strictly in sequence): [ 5525.853432] scsi 0:0:1:1088045124: Direct-Access IBM 2107900 .148 PQ: 0 ANSI: 5 [ 5525.853826] scsi 0:0:1:1088045124: alua: supports implicit TPGS [ 5525.853830] scsi 0:0:1:1088045124: alua: device naa.6005076303ffd32700000000000044da port group 0 rel port 43 [ 5525.853931] sd 0:0:1:1088045124: Attached scsi generic sg10 type 0 [ 5525.854075] sd 0:0:1:1088045124: [sdk] Disabling DIF Type 1 protection [ 5525.855495] sd 0:0:1:1088045124: [sdk] 2097152 512-byte logical blocks: (1.07 GB/1.00 GiB) [ 5525.855606] sd 0:0:1:1088045124: [sdk] Write Protect is off [ 5525.855609] sd 0:0:1:1088045124: [sdk] Mode Sense: ed 00 00 08 [ 5525.855795] sd 0:0:1:1088045124: [sdk] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA [ 5525.857838] sdk: sdk1 [ 5525.859468] sd 0:0:1:1088045124: [sdk] Attached SCSI disk [ 5525.865073] sd 0:0:1:1088045124: alua: transition timeout set to 60 seconds [ 5525.865078] sd 0:0:1:1088045124: alua: port group 00 state A preferred supports tolusnA [ 5526.015070] sd 0:0:1:1088045124: alua: port group 00 state A preferred supports tolusnA [ 5526.015213] sd 0:0:1:1088045124: alua: port group 00 state A preferred supports tolusnA [ 5526.587439] scsi_alloc_sdev: Allocation failure during SCSI scanning, some SCSI devices might not be configured [ 5526.588562] scsi_alloc_sdev: Allocation failure during SCSI scanning, some SCSI devices might not be configured Looking at the code of scsi_alloc_sdev(), and all the calling contexts, there seems to be no reason to use GFP_ATMOIC here. All the different call-contexts use a mutex at some point, and nothing in between that requires no sleeping, as far as I could see. Additionally, the code that later allocates the block queue for the device (scsi_mq_alloc_queue()) already uses GFP_KERNEL. There are similar allocations in two other functions: scsi_probe_and_add_lun(), and scsi_add_lun(),; that can also be done with GFP_KERNEL. Here is the contexts for the three functions so far: scsi_alloc_sdev() scsi_probe_and_add_lun() scsi_sequential_lun_scan() __scsi_scan_target() scsi_scan_target() mutex_lock() scsi_scan_channel() scsi_scan_host_selected() mutex_lock() scsi_report_lun_scan() __scsi_scan_target() ... __scsi_add_device() mutex_lock() __scsi_scan_target() ... scsi_report_lun_scan() ... scsi_get_host_dev() mutex_lock() scsi_probe_and_add_lun() ... scsi_add_lun() scsi_probe_and_add_lun() ... So replace all these, and give them a bit of a better chance to succeed, with more chances of reclaim. Signed-off-by: Benjamin Block Reviewed-by: Bart Van Assche Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- drivers/scsi/scsi_scan.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c index 78ca63dfba4a..9a7e3a3bd5ce 100644 --- a/drivers/scsi/scsi_scan.c +++ b/drivers/scsi/scsi_scan.c @@ -220,7 +220,7 @@ static struct scsi_device *scsi_alloc_sdev(struct scsi_target *starget, struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); sdev = kzalloc(sizeof(*sdev) + shost->transportt->device_size, - GFP_ATOMIC); + GFP_KERNEL); if (!sdev) goto out; @@ -796,7 +796,7 @@ static int scsi_add_lun(struct scsi_device *sdev, unsigned char *inq_result, */ sdev->inquiry = kmemdup(inq_result, max_t(size_t, sdev->inquiry_len, 36), - GFP_ATOMIC); + GFP_KERNEL); if (sdev->inquiry == NULL) return SCSI_SCAN_NO_RESPONSE; @@ -1087,7 +1087,7 @@ static int scsi_probe_and_add_lun(struct scsi_target *starget, if (!sdev) goto out; - result = kmalloc(result_len, GFP_ATOMIC | + result = kmalloc(result_len, GFP_KERNEL | ((shost->unchecked_isa_dma) ? __GFP_DMA : 0)); if (!result) goto out_free_sdev; -- 2.19.1