Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp5596532img; Wed, 27 Mar 2019 11:22:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqxL5o9wey/BCOzniPKm2h7A2kjxylsuKwsAqI7TiiwSz6bGY0St6DtmJRMHJfy6UhqXm4YP X-Received: by 2002:aa7:9389:: with SMTP id t9mr36532151pfe.60.1553710956677; Wed, 27 Mar 2019 11:22:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553710956; cv=none; d=google.com; s=arc-20160816; b=N73GDFy2i9cH0WL/QMOUP8uy1UDhVyQZH5hlV9qTcjYumSDwERMZ0VZYKR0kPu9Zqc KyIZ5ENyxUnE08B0D4nJq6TAjkvCfiRVkORKO4crA8v75AYV95OBNV1QMWKR2dSqo+uo dWr+qjiNiGKGD7Ab9kOusDDAUmOGR1lj47+smsncjRilPmfqQDNflmi+9cIpDQx2M0HJ cIUUl3pf8Gs0JTni6tea1EUh+701dkxz09JvBG3Oj8icu2u+zWDVXnfwYRwuMDSISaY+ sdv3n1AQOQaIwxalsK+tZneBaODNTZCgBO7HdhOw52zXDDlbfONVV3ScmulaH4j69RDf NRJw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=B1a/zaad0cUOraxREJ61rppfJUw7nwTwAA2h/x1HBKs=; b=00v+T7Idin+iknZ14iAW7B8/VUPK9H8R8loAKQQwpWC1sLrC4lIOHlXuzOGJZtuXFk eAJY0MLwv4Fyfw8NWCxCwtqThjfp8ZeMJ2+jAsvwGxirnU1yjjZ61YW2ukAfga0cqnTf WMLuvV71ZIN01n851fKsn2gbSXId3WlmeI0K6NEC9YC5AkA1BroUOSxQVbtJq1ob4ZKG JRLMf7zOtcUMCqHjlebGFIddWF9ldQ5sp0bK8d+eLtMl/NOzdA8Kz+VVFluXMAfEzhee kpblxyjpK+Qtx7kXE8gZc+JpJvZ4VrFp8jZPggDtbF/BwLRECllUGCvB5g4Df8q7elkY lyFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=sUzHQ0Il; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g10si20761141plb.375.2019.03.27.11.22.21; Wed, 27 Mar 2019 11:22:36 -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=sUzHQ0Il; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391195AbfC0SVd (ORCPT + 99 others); Wed, 27 Mar 2019 14:21:33 -0400 Received: from mail.kernel.org ([198.145.29.99]:39308 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390309AbfC0SV1 (ORCPT ); Wed, 27 Mar 2019 14:21:27 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 83C112087C; Wed, 27 Mar 2019 18:21:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553710886; bh=slLbllFuVhZcN5ojRIQlFSAirIPkdKoRiETWE52JJ00=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sUzHQ0IlAYg+uDsxW9kO0Cot+acJDCOdRu7mpRAvYkPmiAVoJYnqzbQkGzyJEWtq/ 7tHfv/jMYfgRGFNlMsAKuO31zTxWQpxS/12LuuBJVDytJ7oHvP9hVlZ52GaAKdV0S4 SuA9eibuC6LZyTBxb+L2z5W3Jtw/jaGkYUVea1lk= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Benjamin Block , "Martin K . Petersen" , Sasha Levin , linux-scsi@vger.kernel.org Subject: [PATCH AUTOSEL 4.9 27/87] scsi: core: replace GFP_ATOMIC with GFP_KERNEL in scsi_scan.c Date: Wed, 27 Mar 2019 14:19:40 -0400 Message-Id: <20190327182040.17444-27-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190327182040.17444-1-sashal@kernel.org> References: <20190327182040.17444-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Benjamin Block [ 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 27a6d3c6cb7c..67f6f134abc4 100644 --- a/drivers/scsi/scsi_scan.c +++ b/drivers/scsi/scsi_scan.c @@ -219,7 +219,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; @@ -1095,7 +1095,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