Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp884915yba; Wed, 24 Apr 2019 11:10:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqxd0i0b04TLKvpiAkaErmVknM4Ap7DOCdvqYJKOJ7tyzAc1YeniCLWup+35MmKj5udQsNRY X-Received: by 2002:a63:7141:: with SMTP id b1mr31887258pgn.331.1556129438511; Wed, 24 Apr 2019 11:10:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556129438; cv=none; d=google.com; s=arc-20160816; b=LC/T5WV0jZ0/YqKofgVgOBkUQ9Yj6EGSn1RwPAZz1yh6sQPqztt1dZV3+fO93FznlR H6S4HJAzeP5XuzrgzeKdejKedIRV+eJwI06AVbs4cKYMZrnda9mIM7oMfLqmsK0vBGGo biSn40x7ljcaa5TPxJ34K0AUg8ZpyE8mUnkF3LA0mbMDh+rPFGzZmd/+/cd8K1Z+4gq7 Ei2XqH2dg50Yq8+sqCakQohh+G1hx2UUgtnOAlLhRQHkTw4UtA8mKIxkBFa5JUKiauGu O/dlWPZ/PSAWMM5BLnogaFjkNSUOXXpn/M7Pk8xrqhEZxiOi63VVRq40z1r6hCWTu+5a 6Fhw== 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=KvRaqjdT4O4i63D0DhsYFFfVoCFPovS35mcc2iTe/Sk=; b=EiOlGz01Ol+D+AN9yDZYDukh7JshlzIAuQIrGS0/FNkvc68kpD6NDKxvs22jwBhlf6 F6QUwO1cadKxKzN5UewqqBBt9dLDuhvllxqw/IFkh2cnQEi1z6Ex1kp9L7lVEYw53Rz7 LGsQPRiJV9QJawvQwGpD/4irtWW5+w1S3qsg4y11Yq+fgF7Fa4OF23lZ7Ph5exYeWIK/ Gmsrq5v98C4I1YxV3Dmvhud8h86dnTbSjed54xipk8BeatM6p68htldwboQ40NDXVgYr HmI7WNGP3juU26wJUlGP7oDHXha6K4RDOABfQBRRyx7uADPZaJ2aGdRDJevd4WF1OXc8 K9/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=VjDsbGJJ; 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 q3si17786725pgp.40.2019.04.24.11.10.23; Wed, 24 Apr 2019 11:10:38 -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=VjDsbGJJ; 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 S2388505AbfDXRQv (ORCPT + 99 others); Wed, 24 Apr 2019 13:16:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:41492 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388495AbfDXRQt (ORCPT ); Wed, 24 Apr 2019 13:16:49 -0400 Received: from localhost (62-193-50-229.as16211.net [62.193.50.229]) (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 C95DE2190A; Wed, 24 Apr 2019 17:16:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1556126208; bh=m5ST6p3HzZAzLfyAyK6h0UVxArB6OQ1zpGSw1iKseaA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VjDsbGJJhJEioERYecZKcrYKIg2G+lXTbJNgKgGovpG4u1aGhIP3vB4KHkdlyXDNH Rn/eVsRSlRof5HqCG06e5GTnPZ3WR3uhh5zs+BeMnmYYwoL/Y8Ydycp02F5Mxo13NQ 1V3/migTljnwDkmbeIZCkCFYnbx8l11tnmNYRu6M= 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.4 029/168] scsi: core: replace GFP_ATOMIC with GFP_KERNEL in scsi_scan.c Date: Wed, 24 Apr 2019 19:07:53 +0200 Message-Id: <20190424170925.413918019@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190424170923.452349382@linuxfoundation.org> References: <20190424170923.452349382@linuxfoundation.org> User-Agent: quilt/0.66 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 [ 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 850ddc5fac04..3e2288af56bc 100644 --- a/drivers/scsi/scsi_scan.c +++ b/drivers/scsi/scsi_scan.c @@ -217,7 +217,7 @@ static struct scsi_device *scsi_alloc_sdev(struct scsi_target *starget, extern void scsi_requeue_run_queue(struct work_struct *work); sdev = kzalloc(sizeof(*sdev) + shost->transportt->device_size, - GFP_ATOMIC); + GFP_KERNEL); if (!sdev) goto out; @@ -791,7 +791,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; @@ -1085,7 +1085,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