From nobody Tue May 7 11:00:23 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1585904458; cv=none; d=zohomail.com; s=zohoarc; b=CoGvqUxML9xKMQBC5slBqz7HlXBk/MFvGgx2fwe0KLMv6CFS0Nb64x5moeUxLQnV86QDPVAXlrbH+o67mE3SFp5L0khpCnel/gf+03ijdQis+5JD7ff+bIDN6hXl5B+udiMiPfHvdYSU5MoToCpxh/3/ltn9qbDUyD0QaWn+jxk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1585904458; h=Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:Message-ID:Sender:Subject:To; bh=Mv/RJfrw7+83pPb7W9RY3+MP8LfpN9mukyRRsXb/aFs=; b=OTLx3ZbZaYFDIamblLweFq3LVc5o62E+UXLKuQR1Sqz0J9h7LYvouWR09LIOOjey8QjwEo66UcpHvlcQ7pdgHZBqK5ipo+w7m8l21fcUBVFBPO5ViLUXz/nyWIk4lkK6encM64tYE9TUVaAfuilJPiHkAqcNchfAX46EOoh9TTI= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1585904458474801.411924093985; Fri, 3 Apr 2020 02:00:58 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jKIBt-00028q-Ld; Fri, 03 Apr 2020 09:00:41 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jKIBs-00028i-Ki for xen-devel@lists.xenproject.org; Fri, 03 Apr 2020 09:00:40 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 967f960e-7589-11ea-bcd3-12813bfff9fa; Fri, 03 Apr 2020 09:00:38 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 8972EAEB1; Fri, 3 Apr 2020 09:00:37 +0000 (UTC) X-Inumbo-ID: 967f960e-7589-11ea-bcd3-12813bfff9fa X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Juergen Gross To: xen-devel@lists.xenproject.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] xen/blkfront: fix memory allocation flags in blkfront_setup_indirect() Date: Fri, 3 Apr 2020 11:00:34 +0200 Message-Id: <20200403090034.8753-1-jgross@suse.com> X-Mailer: git-send-email 2.16.4 X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Juergen Gross , Jens Axboe , Stefano Stabellini , Konrad Rzeszutek Wilk , stable@vger.kernel.org, Boris Ostrovsky , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Commit 1d5c76e664333 ("xen-blkfront: switch kcalloc to kvcalloc for large array allocation") didn't fix the issue it was meant to, as the flags for allocating the memory are GFP_NOIO, which will lead the memory allocation falling back to kmalloc(). So instead of GFP_NOIO use GFP_KERNEL and do all the memory allocation in blkfront_setup_indirect() in a memalloc_noio_{save,restore} section. Fixes: 1d5c76e664333 ("xen-blkfront: switch kcalloc to kvcalloc for large a= rray allocation") Cc: stable@vger.kernel.org Signed-off-by: Juergen Gross Acked-by: Roger Pau Monn=C3=A9 Reviewed-by: Boris Ostrovsky --- drivers/block/xen-blkfront.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c index 915cf5b6388c..3b889ea950c2 100644 --- a/drivers/block/xen-blkfront.c +++ b/drivers/block/xen-blkfront.c @@ -47,6 +47,7 @@ #include #include #include +#include =20 #include #include @@ -2189,10 +2190,12 @@ static void blkfront_setup_discard(struct blkfront_= info *info) =20 static int blkfront_setup_indirect(struct blkfront_ring_info *rinfo) { - unsigned int psegs, grants; + unsigned int psegs, grants, memflags; int err, i; struct blkfront_info *info =3D rinfo->dev_info; =20 + memflags =3D memalloc_noio_save(); + if (info->max_indirect_segments =3D=3D 0) { if (!HAS_EXTRA_REQ) grants =3D BLKIF_MAX_SEGMENTS_PER_REQUEST; @@ -2224,7 +2227,7 @@ static int blkfront_setup_indirect(struct blkfront_ri= ng_info *rinfo) =20 BUG_ON(!list_empty(&rinfo->indirect_pages)); for (i =3D 0; i < num; i++) { - struct page *indirect_page =3D alloc_page(GFP_NOIO); + struct page *indirect_page =3D alloc_page(GFP_KERNEL); if (!indirect_page) goto out_of_memory; list_add(&indirect_page->lru, &rinfo->indirect_pages); @@ -2235,15 +2238,15 @@ static int blkfront_setup_indirect(struct blkfront_= ring_info *rinfo) rinfo->shadow[i].grants_used =3D kvcalloc(grants, sizeof(rinfo->shadow[i].grants_used[0]), - GFP_NOIO); + GFP_KERNEL); rinfo->shadow[i].sg =3D kvcalloc(psegs, sizeof(rinfo->shadow[i].sg[0]), - GFP_NOIO); + GFP_KERNEL); if (info->max_indirect_segments) rinfo->shadow[i].indirect_grants =3D kvcalloc(INDIRECT_GREFS(grants), sizeof(rinfo->shadow[i].indirect_grants[0]), - GFP_NOIO); + GFP_KERNEL); if ((rinfo->shadow[i].grants_used =3D=3D NULL) || (rinfo->shadow[i].sg =3D=3D NULL) || (info->max_indirect_segments && @@ -2252,6 +2255,7 @@ static int blkfront_setup_indirect(struct blkfront_ri= ng_info *rinfo) sg_init_table(rinfo->shadow[i].sg, psegs); } =20 + memalloc_noio_restore(memflags); =20 return 0; =20 @@ -2271,6 +2275,9 @@ static int blkfront_setup_indirect(struct blkfront_ri= ng_info *rinfo) __free_page(indirect_page); } } + + memalloc_noio_restore(memflags); + return -ENOMEM; } =20 --=20 2.16.4