Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp525812ybi; Fri, 12 Jul 2019 00:07:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqxQ/MZbphQ25gpsdSV2dB5Z9wGT/RkgP3HT8i9JZCqfEgyAFNKbUG5WEAPKJSjTFMA1Krjd X-Received: by 2002:a17:90a:8a15:: with SMTP id w21mr9893157pjn.134.1562915277244; Fri, 12 Jul 2019 00:07:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562915277; cv=none; d=google.com; s=arc-20160816; b=VxlPG7CB0Ur+mWStDPaomn0pHhKZO4LDWgPu2AtKB77Bo7p0qPstkA92x1bGMkdhQN Tjqa2Hmhn+pN80qmAcHMjwo0aZcU0gqWpGVjVCkwA+R8NO2mBh3xSEW7WnnSr2wPMhLA hsmRuAHDF6OZgR8mTHDrqhIBjJ1+yBge8S8HW7uC38VBIM0KGsxS3cQAABl/ZndkgkuU AMQSK9GfGp8JzVCxTUl0FD0Hdj8TkyIPTNnrYAAa7SKlw6KKbgRnMZEOgwNxbXYUR3w3 5p3ViHursRCPuUbEywk3ZE884OBBbypU5dmpGeTzee7aRNGKfwjeOjktzqGEgFAQX8mj 3KYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date; bh=9T09nW8hjbJRES3zadrT+hIqrMBso++oZ5ypCr7iNHE=; b=RxSUQa0wVLDPIpDG1Uts33WwQWEit1zO9SJpUzml9gQjNUTPELBtH6q0uAXmmV1Xoz fhc8sXo66UNALiSh0rpj86t6uVkg7lQNWWrEPzkHqcFjUMJ3O+Vom1muZpTRIBwJ0IQ4 NxuJSqaQPm4FbkxAzXHi7OSjY8IHQaaEPxI2Jl5xQuvKvFw+Nyt8b99FXqem37y9PWwL 9t1sp4RTweEe1X1UNGl+WncPUqBA58arQg2CLl1EjrvUomSHpn311Y5FqCbdz8qAGKau qpf4ZMR4NbuUFYpaoGAnEzZNVzi7pccxGV1fULrK47qXW7aIam7rw3MJq+yIXtR+Qsm2 iIIw== 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 f186si7336398pgc.438.2019.07.12.00.07.41; Fri, 12 Jul 2019 00:07:57 -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 S1726225AbfGLHGz (ORCPT + 99 others); Fri, 12 Jul 2019 03:06:55 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:42874 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725871AbfGLHGy (ORCPT ); Fri, 12 Jul 2019 03:06:54 -0400 Received: from pd9ef1cb8.dip0.t-ipconnect.de ([217.239.28.184] helo=nanos) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1hlpdh-0000a5-6M; Fri, 12 Jul 2019 09:06:41 +0200 Date: Fri, 12 Jul 2019 09:06:40 +0200 (CEST) From: Thomas Gleixner To: Ming Lei cc: Sultan Alsawaf , 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 In-Reply-To: <20190712065613.GA3036@ming.t460p> Message-ID: References: <20190712063657.17088-1-sultan@kerneltoast.com> <20190712065613.GA3036@ming.t460p> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 12 Jul 2019, Ming Lei wrote: > On Thu, Jul 11, 2019 at 11:36:56PM -0700, Sultan Alsawaf wrote: > > From: Sultan Alsawaf > > > > Typically, drivers allocate sg lists of sizes up to a few MiB in size. > > The current algorithm deals with large sg lists by splitting them into > > several smaller arrays and chaining them together. But if the sg list > > allocation is large, and we know the size ahead of time, sg chaining is > > both inefficient and unnecessary. > > > > Rather than calling kmalloc hundreds of times in a loop for chaining > > tiny arrays, we can simply do it all at once with kvmalloc, which has > > the proper tradeoff on when to stop using kmalloc and instead use > > vmalloc. > > 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. Thanks, tglx