Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp1618037rbb; Mon, 26 Feb 2024 16:02:26 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXyVQi+SlqmBbyZO+Ag1o/WuDVUDrmilTM+awWa65tMzD/W4Tqgtd+begOjJmFo06N89LphFsyqtTYqoqISzrmZMyrwRqVOt6WiUKl/+A== X-Google-Smtp-Source: AGHT+IGnGk3BSBs39hZhi0V5Xvei/YPrS2keCcisAnuDpu3vV2T+mECp8XHtei7WRWtgR6vkcvay X-Received: by 2002:a17:902:ea0b:b0:1dc:7101:58c0 with SMTP id s11-20020a170902ea0b00b001dc710158c0mr12201117plg.22.1708992146165; Mon, 26 Feb 2024 16:02:26 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708992146; cv=pass; d=google.com; s=arc-20160816; b=vR60F+qzGuZ//naZMZB8EtDaR3E4ES8sk6OHqYJSpFLngFcJrFeH/Ho64fIH2msCXb qSlXIZoug/PxLwmCzgIAUtFh9GTBPRDJSO45tuM1Jjj0A1kgSeuGCFd0Py0S0Fsz/p7+ w53kyXuoQNhx+QMM+5hHVE+YoKp+e6ZMBEQYbDDTCEK19MFWQvtv6Wc/zGKMGZg51tIx GvsEShqHK1zjwWgnMuw06PmXuZN/YGQfUrnKQxBtEVa71CSBJpq+oniQaWjHEpFj/3qK aZY7t0ikI9R0yc1eSlw5MqJKbW1B5/nA8dhTjSdYa0bzn8QUR+COOwsqx3pChrbDyOjg ZeVg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=ra7j2veHt8ckgDfEUqJ6n9hg5jJXbYYJjjFPbVavXog=; fh=jHd8Vn28HaiwTASVYSWq8hlXxoUHWK1znSRjCKlVgOU=; b=EgZ8QgWxOJ4Ad0aG3LIngonhLYVlALRwWoQ6RY2kZtbYwfSySGxiZYHuig67iEJxhu MLN5N9bQqjPy6CgpR+7aM5fEkEPPZD+OKATGko7aC0+5x0jqG446nvHbwSTImdPUww+O Fe916d3bCJYuD2r8JF8HTOWZilwaydZimE1/h0OxvnFTg59mJl2dyTOjOMayHDvfLKqt OLyvpfKUbUPLsNGB7DJnvReJtpInnlwO1cIEo8F4Ht4Y+4ZvPwEbHlqYvVqMGaOF1uNa YhTzwWdzfWU3dwTzXOdW18hwFVHrTWgkB9GmUNqX6BhPDim12pRVexBZtmfiRvR6VCYq PXdQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="e+/WSWYb"; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-82459-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-82459-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id s12-20020a17090302cc00b001d9e3c8e3d7si383562plk.157.2024.02.26.16.02.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 16:02:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-82459-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="e+/WSWYb"; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-82459-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-82459-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id B63A728895A for ; Tue, 27 Feb 2024 00:02:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1EB2B20EE; Tue, 27 Feb 2024 00:02:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="e+/WSWYb" Received: from mail-ej1-f45.google.com (mail-ej1-f45.google.com [209.85.218.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7A1BE1366 for ; Tue, 27 Feb 2024 00:02:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708992139; cv=none; b=PUFIl485mYSpfQYm2dv9tXMlJSg/Ghucsk3pADYXcuYrE6twNiZGitqeI5wA3GN5SPMwVXJ10h2wkbUvEgI2sdcv1HMXsp5scuHnmOnYDNsusrMIavBvu9xSxs+WIww/7JgLfTSi0P2gDxs+hGmAEDTkruCzz9SVpgaEdnWy2Eg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708992139; c=relaxed/simple; bh=pd6yrnTC+hRr0/Z0yLyCvqH0hBN/UOqqiHViIEB2PNE=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=nCos0lY4TAOorQZvqPES0YcySIBlB1fvD10GgGTPWIY8UhMOKZJHbxq6bmp9ZMibZTJKLcWbey5ZayNDf0GVaHQA8DybvkjZECtYhKSIfw78gqzYf4HMT7PjI9PXkngByFYa2nojQozg26nd30T/hyQNIVx3wiiyJGmcJ/muuGc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=e+/WSWYb; arc=none smtp.client-ip=209.85.218.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-ej1-f45.google.com with SMTP id a640c23a62f3a-a26fa294e56so627886366b.0 for ; Mon, 26 Feb 2024 16:02:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1708992136; x=1709596936; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=ra7j2veHt8ckgDfEUqJ6n9hg5jJXbYYJjjFPbVavXog=; b=e+/WSWYb/DzBJ9b7k+Hpf5I6r/XPurn7d50AnX7ML1wRPAPjEhxBuMFYB1kE6qtJ0A v7pfCtufGdnaeGDme7Uxe5R7UC9ROWbr0ZG/rGOooa1d84b7lxWA8ky2N5TODDtmgncA tYwYLftxJLuiiQZ+IZMbg6WKZm6R6gCXNwVcM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708992136; x=1709596936; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ra7j2veHt8ckgDfEUqJ6n9hg5jJXbYYJjjFPbVavXog=; b=O0MOnSRsqMq3Q07MwMad30PfbWkHtxsY1zcQdVu8CIuQhDkUZint8fmyzKXPgl7KVx yDnUewnMe511rc9rYXHgK2sMf/74l+GolmJv2U8jvJbg/Wpo1Qo84aOI0q0a4SAQoSLR z+f/c16YtXAyY5JMKDlRcnr9C3LNhsPkH2i7vvSPxHeWq2MgSlrQA6Qvjlr8+5ZifGFu HlxO1bfTDb6+xp9Vzw0Vj8FTfJwRNhXGKY+u92tvO8RzaYEpVMSEz7MbD0RwrXlyXwxO ZQQ3IcIyhmtRvkluUhEWVrWdGyBWO7klZscp61ihs4EOtftLg17LgaNVxdbAw2m8WIjc mIQg== X-Forwarded-Encrypted: i=1; AJvYcCVzzbgtU2sGf+PLyrZATucHCrZywq8T9fLq1G/qIFUycl/bRLqGC2oHsIrz7fLiDBZ6pngvl8Ue+To6YwxZcNfUOz4Lx2b4hid+PmxW X-Gm-Message-State: AOJu0YxgAQjPK0rMAiLQi3wP4G7epRl9ulcmcqdjAgxP21tQe6ChnnSG CViLiamNEx9PD175eb4AfOUDG6r1avpGtIpO/JIK3/3Fj9b6KM1S/gFyB2S/zuVcV4BifYAIZet Lim1Y X-Received: by 2002:a17:906:a046:b0:a43:35f1:944e with SMTP id bg6-20020a170906a04600b00a4335f1944emr3971959ejb.22.1708992135707; Mon, 26 Feb 2024 16:02:15 -0800 (PST) Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com. [209.85.128.43]) by smtp.gmail.com with ESMTPSA id m16-20020a170906235000b00a3d153fba90sm205910eja.220.2024.02.26.16.02.15 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 26 Feb 2024 16:02:15 -0800 (PST) Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-412a9f272f4so20565e9.0 for ; Mon, 26 Feb 2024 16:02:15 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCWYXp5FNslpCq5eqEo8AUDTTR2kznCjAZtnF5UdBQkXI4zfgbCvBdcIZ1odtueJAulB0P7YsDctDHrDO9HMwm9xoU6fMIrkNKJk/8+N X-Received: by 2002:a05:600c:501f:b0:412:5616:d3d with SMTP id n31-20020a05600c501f00b0041256160d3dmr41903wmr.7.1708991743417; Mon, 26 Feb 2024 15:55:43 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240205092626.v2.1.Id9ad163b60d21c9e56c2d686b0cc9083a8ba7924@changeid> In-Reply-To: <20240205092626.v2.1.Id9ad163b60d21c9e56c2d686b0cc9083a8ba7924@changeid> From: Doug Anderson Date: Mon, 26 Feb 2024 15:55:28 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2] regset: use kvzalloc() for regset_get_alloc() To: Alexander Viro , Christian Brauner Cc: Mark Brown , Catalin Marinas , Will Deacon , Dave Martin , Oleg Nesterov , linux-arm-kernel@lists.infradead.org, Matthew Wilcox , Eric Biederman , Jan Kara , Kees Cook , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi, On Mon, Feb 5, 2024 at 9:27=E2=80=AFAM Douglas Anderson wrote: > > While browsing through ChromeOS crash reports, I found one with an > allocation failure that looked like this: > > chrome: page allocation failure: order:7, > mode:0x40dc0(GFP_KERNEL|__GFP_COMP|__GFP_ZERO), > nodemask=3D(null),cpuset=3Durgent,mems_allowed=3D0 > CPU: 7 PID: 3295 Comm: chrome Not tainted > 5.15.133-20574-g8044615ac35c #1 (HASH:1162 1) > Hardware name: Google Lazor (rev3 - 8) with KB Backlight (DT) > Call trace: > ... > warn_alloc+0x104/0x174 > __alloc_pages+0x5f0/0x6e4 > kmalloc_order+0x44/0x98 > kmalloc_order_trace+0x34/0x124 > __kmalloc+0x228/0x36c > __regset_get+0x68/0xcc > regset_get_alloc+0x1c/0x28 > elf_core_dump+0x3d8/0xd8c > do_coredump+0xeb8/0x1378 > get_signal+0x14c/0x804 > ... > > An order 7 allocation is (1 << 7) contiguous pages, or 512K. It's not > a surprise that this allocation failed on a system that's been running > for a while. > > More digging showed that it was fairly easy to see the order 7 > allocation by just sending a SIGQUIT to chrome (or other processes) to > generate a core dump. The actual amount being allocated was 279,584 > bytes and it was for "core_note_type" NT_ARM_SVE. > > There was quite a bit of discussion [1] on the mailing lists in > response to my v1 patch attempting to switch to vmalloc. The overall > conclusion was that we could likely reduce the 279,584 byte allocation > by quite a bit and Mark Brown has sent a patch to that effect [2]. > However even with the 279,584 byte allocation gone there are still > 65,552 byte allocations. These are just barely more than the 65,536 > bytes and thus would require an order 5 allocation. > > An order 5 allocation is still something to avoid unless necessary and > nothing needs the memory here to be contiguous. Change the allocation > to kvzalloc() which should still be efficient for small allocations > but doesn't force the memory subsystem to work hard (and maybe fail) > at getting a large contiguous chunk. > > [1] https://lore.kernel.org/r/20240201171159.1.Id9ad163b60d21c9e56c2d686b= 0cc9083a8ba7924@changeid > [2] https://lore.kernel.org/r/20240203-arm64-sve-ptrace-regset-size-v1-1-= 2c3ba1386b9e@kernel.org > > Signed-off-by: Douglas Anderson > --- > > Changes in v2: > - Use kvzalloc() instead of vmalloc(). > - Update description based on v1 discussion. > > fs/binfmt_elf.c | 2 +- > kernel/regset.c | 6 +++--- > 2 files changed, 4 insertions(+), 4 deletions(-) Just wanted to check in to see if there's anything else that I need to do here. Mark's patch to avoid the order 7 allocations [1] has landed, but we still want this kvzalloc() because the order 5 allocations can't really be avoided. I'm happy to sit tight for longer but just wanted to make sure it was clear that we still want my patch _in addition_ to Mark's patch and to see if there was anything else you needed me to do. Thanks! [1] https://lore.kernel.org/r/20240213-arm64-sve-ptrace-regset-size-v2-1-c7= 600ca74b9b@kernel.org