From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 17B41C48BF6 for ; Mon, 26 Feb 2024 23:55:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7FE8C4401CE; Mon, 26 Feb 2024 18:55:51 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7872744017F; Mon, 26 Feb 2024 18:55:51 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6288F4401CE; Mon, 26 Feb 2024 18:55:51 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 3808644017F for ; Mon, 26 Feb 2024 18:55:51 -0500 (EST) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 09AD08060E for ; Mon, 26 Feb 2024 23:55:51 +0000 (UTC) X-FDA: 81835615302.03.7DDCBC8 Received: from mail-ed1-f44.google.com (mail-ed1-f44.google.com [209.85.208.44]) by imf17.hostedemail.com (Postfix) with ESMTP id 18FDD4000F for ; Mon, 26 Feb 2024 23:55:48 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=FJb34HUc; dmarc=pass (policy=none) header.from=chromium.org; spf=pass (imf17.hostedemail.com: domain of dianders@chromium.org designates 209.85.208.44 as permitted sender) smtp.mailfrom=dianders@chromium.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708991749; a=rsa-sha256; cv=none; b=08a6ipQU/b947Sor668BAGq8hPkAvnmSW8mGBqy2Df0ISHxWEatjr3hAbNsa2G/iFvCVdI C2jWr0DiCAM2N1RHJNWxuEA4c4hlVUHgTqdkUdXp5ks9YpBNq4/RbAFGDyJBKqoMHiAckN RH+Dy+56rLWwq3xGi7fPxlKe5R0cMJg= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=FJb34HUc; dmarc=pass (policy=none) header.from=chromium.org; spf=pass (imf17.hostedemail.com: domain of dianders@chromium.org designates 209.85.208.44 as permitted sender) smtp.mailfrom=dianders@chromium.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1708991749; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=ra7j2veHt8ckgDfEUqJ6n9hg5jJXbYYJjjFPbVavXog=; b=5kxo6i5wOI0ghGnzE1TXr5870+YDbhP/oatCnU0Y13svgKIuHY4AgOXQ/1D2N2xbMmRv85 zUm70Dj69YMyogkfDc6YZORfjbksbNmvK/FJLfeg78MQtarpGQsD9ZB9Kjc98JPaQ+vcd9 NNkgukqFp0sIW/bKvp0uVlqbaLWwkzI= Received: by mail-ed1-f44.google.com with SMTP id 4fb4d7f45d1cf-5654f700705so4845885a12.1 for ; Mon, 26 Feb 2024 15:55:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1708991745; x=1709596545; darn=kvack.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=FJb34HUc+gKQ/jHIVRdP37yAWVQwUkgT3UNJkrmje4GBM/zo7sGlKsThQAe+ktZITG ITK0/5HqRNeOyytDAxFcsWHpfh3Q2f2aj63CXy9/rkLqEv5bRkiIA0LUBcbQLMKoXOWK JW3TP0msnf0WWVfsgdV8qDihCEx4bI2W8TG6E= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708991745; x=1709596545; 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=pqxzEWPbBs39nrBf3ZeSERyILpKCELIstZ6eWIqlpNOqa9MQvQ0T+uIpkg9/WlMATX V2eS9wrTWMR4cr5FIaNLbGiIog9kp4W85Gj8YhWaqsakas9Vl9qAwlPmLZRKw+IvEZ17 bva8Pwmb3q42dGgf+QXhjhKDjBb2Z0KLuj1Gofg0lPEyljb5JVuwcNkz9uPXZXW77qE1 5JR/MuTZAp1PGBRrmi0UdEHFQEr2mU8mSIft6P+0vn87wNP/U7ku9wwH6uXQwlERU/nb VvsZaLWurGk1vRfR1Hqy86ibRE7364VSbFt2f6cKUsotXgGktsql8I7qOWMFC7m1L0OB oNBA== X-Forwarded-Encrypted: i=1; AJvYcCUuGnW+4v7ZBpFe5SSePcWYhR2CWYLYP7QPv6giH7SRnd/ezYn4FPtQByA23BqInOEsT/545kI+n/Xq3pmi5eNbvy8= X-Gm-Message-State: AOJu0Yyw1GbL+tHofNQ4TBGj7KH/W1KCBatYd8d7FDeXpdGfEVZ7hCT1 SThpKPlL1iiOBnZzMgubysI30896GxMrA3qF5pwEk9SAhpTXpsMS/S4VKeYOt85zmlnSC1eRbP3 LAzSY X-Google-Smtp-Source: AGHT+IHnZ5uctSDeTkjL8VcY9OHhJcRtxpPKuVsItISXJa3swlY3mBIXBEPziw3sLRohRme0GOoIBg== X-Received: by 2002:a17:907:101b:b0:a3f:5ad2:1ff0 with SMTP id ox27-20020a170907101b00b00a3f5ad21ff0mr5731398ejb.46.1708991745143; Mon, 26 Feb 2024 15:55:45 -0800 (PST) Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com. [209.85.128.46]) by smtp.gmail.com with ESMTPSA id jo23-20020a170906f6d700b00a43236bc0a1sm212926ejb.13.2024.02.26.15.55.43 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 26 Feb 2024 15:55:44 -0800 (PST) Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-412a2c2ce88so9815e9.1 for ; Mon, 26 Feb 2024 15:55:43 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCUwj/4nM2wrmOdDL7m/N/RfwEbC8EJY2oqpTKg+RWGhoGktvhoy9ACk9GqFQGd5fjyMj/HbEUH9tKWpMkXFhOE99e4= 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) 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 X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 18FDD4000F X-Stat-Signature: 8scox6zjnia6w8rjf5gm3nbgfeexp957 X-HE-Tag: 1708991748-93020 X-HE-Meta: U2FsdGVkX1+pivI3LK69gsEGxjL35PJ68s71C6s0VKcV8Qa8WPoTnyQv8MNN258IJMC7mwoO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ner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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