Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp5117445yba; Tue, 30 Apr 2019 09:24:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqwwNuLFhFq4eSmoBAJo/Vh+Cd7jCqVH24k+3hsENjhD9oBO+eggFPkJc0KcVDEnxMtpd8/A X-Received: by 2002:a63:8342:: with SMTP id h63mr2960454pge.251.1556641445186; Tue, 30 Apr 2019 09:24:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556641445; cv=none; d=google.com; s=arc-20160816; b=J605jRDWIOQ1h+zMKejP5tzBUqGqThhjUfcQNBF5jhFe6n9stlChqhP5d6KilFOtUA dBiOBR5ss/cT/aMAT0pEfZjbfmkuTVbjifGSx9Wn4Wr1y4oYa0ks7kI7Ze2Uar4Jd2eT dk8mxyCY4AaNoqOM/RWExVprEk67OxkTFX7X5JMsCg8V3a/qGT1F/rf0KJeVxvaETRac 6JJOcdV9/ov/ug5OCOWVNj/KNZSfHBm7X3CZiHUtrfDpUUn8hI0CeyoHwEcKhupq/rnK DFdt5ZWu8J5njGIwGhI57clUcwm7yzDsg5osbh6Q0Q0qni2ZbenFfgU8S4+vgMdbVdta tX4w== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=BJ/Szi3F8e7NtlTHUjW71joUshnEhSvTTq7CNPbfAFM=; b=BzIhsmQnOF0LUNWJYHfFSTJ7mVDewFWbvTRTeshqdQsjkRbbI6A/LamnX4xCTUq3pp xOqpxevloVYbZyjnA4Q7npttTrsGMCwIBH6dIcp2OA3H8soMyrSZh7K5lZsmQq5gPUZE biM3DoQdzeNAmBstLTbiG+Dx5MyQ/9sxdb0+pglx1X1fZeLoodbzh95AGozDDlM2dNT8 Ww2v8Hb8iD1nuBAaTTRUzqXLpDBftTXNqBukcDh0a5uUTQGJg/iwgy+IWIGM6cpr0QaG 8KByq3akCBPVf1qhJbKOstCvyeEhK4yDdysKU2bHyT4A4+Kt4EuQRmKQd0piwq+hVZuz YM1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel-dk.20150623.gappssmtp.com header.s=20150623 header.b=pmXYskxn; 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 n72si42480241pfi.0.2019.04.30.09.23.49; Tue, 30 Apr 2019 09:24: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; dkim=pass header.i=@kernel-dk.20150623.gappssmtp.com header.s=20150623 header.b=pmXYskxn; 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 S1726580AbfD3QVH (ORCPT + 99 others); Tue, 30 Apr 2019 12:21:07 -0400 Received: from mail-io1-f67.google.com ([209.85.166.67]:42952 "EHLO mail-io1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726552AbfD3QVH (ORCPT ); Tue, 30 Apr 2019 12:21:07 -0400 Received: by mail-io1-f67.google.com with SMTP id m188so12703625ioa.9 for ; Tue, 30 Apr 2019 09:21:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=BJ/Szi3F8e7NtlTHUjW71joUshnEhSvTTq7CNPbfAFM=; b=pmXYskxn//lXkmPtU0nKHsepkH35YTlpXRbi3z1GPYRPvLxbJy0szBBpr4wsdKWdqD WzkQV3inBVHiv5/eCljE8Sy8Wp3igwctGaYx5A+tBS7L/3vNeOqopXFTpO++bQeTEZtp fn46rDkxgYWOd969ztK/LXdMUveJ9dP6q9tQ+JzpBkYl3WjHP/TxLfwituIjjUBaVE/n Q4WjNhxp5e84/fkOvc+r9tCrsI1rc79FRdw0qDWRE06QyQx/5TfnImsCxeErm0FUn5I+ 8ETmxQ7uFqF0YEbtSXaePDNF9MomgkLLC8sPJ8CesbvKa2IywcVknjsL3Jmg7I+3LVLP E2AQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=BJ/Szi3F8e7NtlTHUjW71joUshnEhSvTTq7CNPbfAFM=; b=ew0CY71fBqqruAFqjrWHTU3fs/TLmJEHS0VaLzvWGY1iO7FR1rAia2vOYGNCYGiGKE o+o4i643B7+CK4I2fCye5/04Vk7VEzusUQOc52+6Qs5HbKuR4p03FPjkeXjFfbhz2fld AOf9VEWdPfArSxfUrVbdxkn33jKCxVFtQodNDqulDGgF4erZFY0HdrYfkRPpyCmiwQXj ydPLv3cnITd5Ai9vE0gw3jmN2kqVvFqI0s6ZkUE8JzIThe6bhb0nXnUzyh5ySp0hNsmT fIesowUTr32gh3Talau9CbHrKMJ+jYpRJENMY/ENi53GTG571r2Iz+Q6lveiUONyYI5k yT9w== X-Gm-Message-State: APjAAAWGCQhDgSMnv+ZHObtHnh4PQ+AcZe2PY4+2N2WDDoELjxvF2rjH vDerUzHblW3+3EO+RONPcyO74fh9qnCRxg== X-Received: by 2002:a5e:d702:: with SMTP id v2mr5547885iom.236.1556641266170; Tue, 30 Apr 2019 09:21:06 -0700 (PDT) Received: from [192.168.1.158] ([216.160.245.98]) by smtp.gmail.com with ESMTPSA id w81sm1602623itf.23.2019.04.30.09.21.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 30 Apr 2019 09:21:04 -0700 (PDT) Subject: Re: [PATCH] io_uring: avoid page allocation warnings To: Mark Rutland , Matthew Wilcox Cc: linux-kernel@vger.kernel.org, Alexander Viro , linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org References: <20190430132405.8268-1-mark.rutland@arm.com> <20190430141810.GF13796@bombadil.infradead.org> <20190430145938.GA8314@lakrids.cambridge.arm.com> From: Jens Axboe Message-ID: Date: Tue, 30 Apr 2019 10:21:03 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <20190430145938.GA8314@lakrids.cambridge.arm.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 4/30/19 8:59 AM, Mark Rutland wrote: > 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. kvmalloc() is fine, the io_uring code doesn't care about the layout of the memory, it just uses it as an index. -- Jens Axboe