Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp536994ybi; Fri, 12 Jul 2019 00:20:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqyXJ88GgPFPd7lK0B9w99pzLbxeduJZhVxVKs2GEJwV4CWCPKtrZz1pBjTqAeGaX4Wm2va4 X-Received: by 2002:a17:90a:cb01:: with SMTP id z1mr9763233pjt.93.1562916005067; Fri, 12 Jul 2019 00:20:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562916005; cv=none; d=google.com; s=arc-20160816; b=kpxpkE42Cwvnv5RgaE2svt9AnXIbGxWUngd/berXDPaWR9Xin2/BQWjKpoCbodlSrY f91tONaFPMYIBOdhB+iUzEF5Pe+1+OZLhaCI1v1jSa9XLh5Rg0yM4cWsf7FW5mA5Q4oi vFk59jQ9hqfYWgb+44+KhR/9B9rfMwCbRwwOW3ui5QjPls9PrRxP0o9XTne03x4n7bVJ 7DZ7sYk2lWJH3PVaIyyXfuo1ooO/bsr5+Kd6xiAQF4g7xcjiyAERa4I0iT6aOjuvQer7 11U+1RBpwZIiwtB1y4UIbBMlRgsWD5bZM0N5oXxqrCS0izgGbFlWv4OaT9sBMX+RXpSB WU2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=HXsmvvgoYnPg11ObtkwJ6+EqE/8B+1DtT9GF/thKYqI=; b=LBhaqTXj2p70WcLLpns+hRa4DDQ0ugPCGJZzd0m85KTnQmh23A2nLTCPfEIfCPceWQ 3A8jj4ZQs2ncojHBr8FPYY3xsbZuRRG/pzVfGsKlHga6G8Gw7Ca2CwP/Wn2oQz6u5GrR 1wKtMeygQSDZJGuxXytiC07P5TICBhOrmd15c0VwpXbiBPfLIjrIKBMUBUC3N/dIKEEb 4wQcGj9qTZ3z2W170lUi5kGeKvR2+O6xmKDAtWS9gv6U31TsRMMea27oSFClZUmp0P49 q4aNLUheWNj0SfSa7uHygrjt1awUaycf7A/p/rt/5gyUDX1yBKJ8MgyyWQMIPUM8Z/j1 e1pg== 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 2si7003720pla.22.2019.07.12.00.19.48; Fri, 12 Jul 2019 00:20:05 -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 S1726138AbfGLHRi (ORCPT + 99 others); Fri, 12 Jul 2019 03:17:38 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:43771 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725840AbfGLHRi (ORCPT ); Fri, 12 Jul 2019 03:17:38 -0400 Received: by mail-pf1-f196.google.com with SMTP id i189so3906328pfg.10 for ; Fri, 12 Jul 2019 00:17:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=HXsmvvgoYnPg11ObtkwJ6+EqE/8B+1DtT9GF/thKYqI=; b=MWgO6EQKNROUZVUyfVy4xAEUxy6t8HS6dh288+v0wwKxcMQSAklHS0xuRiyZY6eME6 MgxH9kQcRm6TKlTTGQOKQGLht7Y/+x9N07KvyUuPAFz1Ip8z8oSgaisMugwnJBIAXfL8 teIsRjYEOFY1puFjNXzlQmyXpue+E+QiXmEnxGY6PEoPwmkTOeto7mljCXVc5uKAI9a7 acmViAd6DexY5ZMM2kpWOTuaCEPhTXu1cxncKHy8gsQENwwCv/48+hzF3Barse+Q3cLi dalrKzgEgqKxU4ls5dumFuQ+fFsZ+lrTKTGrcy0lOlna/foAF8PaRoQr544DbJNJe7oh nc1w== X-Gm-Message-State: APjAAAUsbzKdh4eTFDpC4dwrZps2HvQJ+cN1p+Cfz1ORCfiqu6OAkY1B FGabhkYc/ZzqUv/JQ3ddBU0= X-Received: by 2002:a63:6ec6:: with SMTP id j189mr9352493pgc.168.1562915857427; Fri, 12 Jul 2019 00:17:37 -0700 (PDT) Received: from sultan-box.localdomain ([2601:200:c001:5f40:3dac:1a9b:f47c:b78e]) by smtp.gmail.com with ESMTPSA id r6sm12610256pjb.22.2019.07.12.00.17.36 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 12 Jul 2019 00:17:36 -0700 (PDT) Date: Fri, 12 Jul 2019 00:17:18 -0700 From: Sultan Alsawaf To: Thomas Gleixner Cc: Ming Lei , Jason Gunthorpe , Palmer Dabbelt , "Martin K. Petersen" , Gal Pressman , Allison Randal , Christophe Leroy , linux-kernel@vger.kernel.org Subject: Re: [PATCH] scatterlist: Allocate a contiguous array instead of chaining Message-ID: <20190712071718.GA17944@sultan-box.localdomain> References: <20190712063657.17088-1-sultan@kerneltoast.com> <20190712065613.GA3036@ming.t460p> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.12.1 (2019-06-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jul 12, 2019 at 09:06:40AM +0200, Thomas Gleixner wrote: > On Fri, 12 Jul 2019, Ming Lei wrote: > > vmalloc() may sleep, so it is impossible to be called in atomic context. > > Allocations from atomic context should be avoided wherever possible and you > really have to have a very convincing argument why an atomic allocation is > absolutely necessary. I cleaned up quite some GFP_ATOMIC users over the > last couple of years and all of them were doing it for the very wrong > reasons and mostly just to silence the warning which is triggered with > GFP_KERNEL when called from a non-sleepable context. > > So I suggest to audit all call sites first and figure out whether they > really must use GFP_ATOMIC and if possible clean them up, remove the GFP > argument and then do the vmalloc thing on top. Hello Thomas and Ming, It looks like the following call sites are atomic: drivers/crypto/qce/ablkcipher.c:92: ret = sg_alloc_table(&rctx->dst_tbl, rctx->dst_nents, gfp); drivers/crypto/ccp/ccp-crypto-aes-cmac.c:110: ret = sg_alloc_table(&rctx->data_sg, sg_count, gfp); drivers/crypto/ccp/ccp-crypto-sha.c:103: ret = sg_alloc_table(&rctx->data_sg, sg_count, gfp); drivers/spi/spi-pl022.c:1035: ret = sg_alloc_table(&pl022->sgt_rx, pages, GFP_ATOMIC); drivers/spi/spi-pl022.c:1039: ret = sg_alloc_table(&pl022->sgt_tx, pages, GFP_ATOMIC); The crypto ones are conditionally made atomic depending on the presence of CRYPTO_TFM_REQ_MAY_SLEEP. Additionally, the following allocation could be problematic with kvmalloc: net/ceph/crypto.c:180: ret = sg_alloc_table(sgt, chunk_cnt, GFP_NOFS); This is a snippet from kvmalloc: /* * vmalloc uses GFP_KERNEL for some internal allocations (e.g page tables) * so the given set of flags has to be compatible. */ if ((flags & GFP_KERNEL) != GFP_KERNEL) return kmalloc_node(size, flags, node); Use of GFP_NOFS in net/ceph/crypto.c would cause kvmalloc to fall back to kmalloc_node, which could cause problems if the allocation size is too large for kmalloc_node to reasonably accomodate. Also, it looks like the vmalloc family doesn't have kvmalloc's GFP_KERNEL check. Is this intentional, or does vmalloc really not require GFP_KERNEL context? Thanks, Sultan