Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp5023057yba; Tue, 30 Apr 2019 08:01:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqyM+SFP/Kqgjw7TVEpZlFOBEaReVWa/0HsGW5ChvTbxobFL4YTSx+Lc6BMkOtubqaOuWZPD X-Received: by 2002:a62:304:: with SMTP id 4mr69196580pfd.99.1556636481876; Tue, 30 Apr 2019 08:01:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556636481; cv=none; d=google.com; s=arc-20160816; b=qPUtCIccZU2q5qPgrgbD8AHfkp4zIDw/AaIm2TYi9+/nLA6VuBmQ1UlI+TRkHg/+Ax A44HUoJCYAH1fbQCAKCxk69zGBE7tdE3Tsl90XPrEvbVsdvaurnJ7mYja1QAUm/V5Dlp BKDMH4cohX9xw92+gzAm4z+YrU2X37u0e5FX+uuzoY4E3Z7yu483Nuoapch3q+/0m6cb 5kaDsN2DsGuwR6L3f1m9WPK6+AeR75QtW/WhiiioDUHyNOcdEqjn12BuS4o0VSfJvSjJ LoUeAginesciezhBKR6jKhMlk2UZLacgLahPWa+MPkKiTVdW1yQCIUkdJUt6H5/3Pb9g 9D7A== 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=LwxfNfPFq54va09Aw8BEk7h+uLe56hmFhg8Sl+es+LQ=; b=mRc9MUDlYGFgVU+DeGFN7Ph/HMc1cw6bUJ0w0MR11h9bPboPbnhKeDI2iYrUNyEy35 mc8FAwAW7Jttaeyk0zSgyZUAMHaWU3ml2r+3Cchis01Kn/0DioY+6bvTMh556j4dm3Rm YkxBZbRspGJLm0QuspyX9j3EWMkT/7ZSyvMtJ3NEyRDlAUV1ucMb1fmGOFhTdo8axaDV a+S6+0ZrSb8Hq8+OkEXXjcxJSi5X3E/nvFsLkmNIbYzUmj/vNa53WULEY0H5AUuji6fI DRdQjfLPpsxxkhpX0hFCeAIaixpRmQDiEcT+8TpSbxezkZgG8KOi3qSFW3XQEe+5DjaE jB+g== 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 s79si39998098pfa.69.2019.04.30.08.01.01; Tue, 30 Apr 2019 08:01:21 -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 S1726460AbfD3O7s (ORCPT + 99 others); Tue, 30 Apr 2019 10:59:48 -0400 Received: from foss.arm.com ([217.140.101.70]:48686 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726384AbfD3O7q (ORCPT ); Tue, 30 Apr 2019 10:59:46 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id A0E68374; Tue, 30 Apr 2019 07:59:45 -0700 (PDT) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 608553F719; Tue, 30 Apr 2019 07:59:44 -0700 (PDT) Date: Tue, 30 Apr 2019 15:59:39 +0100 From: Mark Rutland To: Matthew Wilcox Cc: Jens Axboe , linux-kernel@vger.kernel.org, Alexander Viro , linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org Subject: Re: [PATCH] io_uring: avoid page allocation warnings Message-ID: <20190430145938.GA8314@lakrids.cambridge.arm.com> References: <20190430132405.8268-1-mark.rutland@arm.com> <20190430141810.GF13796@bombadil.infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190430141810.GF13796@bombadil.infradead.org> User-Agent: Mutt/1.11.1+11 (2f07cb52) (2018-12-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Apr 30, 2019 at 07:18:10AM -0700, Matthew Wilcox wrote: > On Tue, Apr 30, 2019 at 02:24:05PM +0100, Mark Rutland wrote: > > In io_sqe_buffer_register() we allocate a number of arrays based on the > > iov_len from the user-provided iov. While we limit iov_len to SZ_1G, > > we can still attempt to allocate arrays exceeding MAX_ORDER. > > > > On a 64-bit system with 4KiB pages, for an iov where iov_base = 0x10 and > > iov_len = SZ_1G, we'll calculate that nr_pages = 262145. When we try to > > allocate a corresponding array of (16-byte) bio_vecs, requiring 4194320 > > bytes, which is greater than 4MiB. This results in SLUB warning that > > we're trying to allocate greater than MAX_ORDER, and failing the > > allocation. > > > > Avoid this by passing __GFP_NOWARN when allocating arrays for the > > user-provided iov_len. We'll gracefully handle the failed allocation, > > returning -ENOMEM to userspace. > > > > We should probably consider lowering the limit below SZ_1G, or reworking > > the array allocations. > > I'd suggest that kvmalloc is probably our friend here ... we don't really > want to return -ENOMEM to userspace for this case, I don't think. Sure. I'll go verify that the uring code doesn't assume this memory is physically contiguous. I also guess we should be passing GFP_KERNEL_ACCOUNT rateh than a plain GFP_KERNEL. Thanks, Mark.