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 B4456C54E67 for ; Thu, 28 Mar 2024 14:16:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2F9086B0082; Thu, 28 Mar 2024 10:16:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2A9A36B0085; Thu, 28 Mar 2024 10:16:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 14AD16B0087; Thu, 28 Mar 2024 10:16:58 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id EEDBC6B0082 for ; Thu, 28 Mar 2024 10:16:57 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 7C5281C0202 for ; Thu, 28 Mar 2024 14:16:57 +0000 (UTC) X-FDA: 81946649274.14.820B8A9 Received: from mail-qv1-f41.google.com (mail-qv1-f41.google.com [209.85.219.41]) by imf09.hostedemail.com (Postfix) with ESMTP id 6B8D1140019 for ; Thu, 28 Mar 2024 14:16:55 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=aCKcEelQ; dmarc=pass (policy=none) header.from=chromium.org; spf=pass (imf09.hostedemail.com: domain of dianders@chromium.org designates 209.85.219.41 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=1711635415; 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=TZkkr+8BMbOQbcHkSO5h3H5iApjHoCs8BFl7+oRwVKE=; b=VSpPWNiJihrJbTSUkjwvAG6OkTsRWqBh3i/MJxZxbl8v/thMetdCG9/x8afZI727nH0Wvy jT5U4Qj3Ob8asGEy16HcPw+QuoX1bNxDr+5ePkF/XHTyR8WKcx8u2OSAzkwcf/mYWEwi7Z az2AqrJBF4G49uCrGuecf7P2CyB9qzU= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=aCKcEelQ; dmarc=pass (policy=none) header.from=chromium.org; spf=pass (imf09.hostedemail.com: domain of dianders@chromium.org designates 209.85.219.41 as permitted sender) smtp.mailfrom=dianders@chromium.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1711635415; a=rsa-sha256; cv=none; b=qlI7l9bvkqnJvPWZBNxwT8lj3YhVOvP8ri1csmLUCYi678L/OpiZUxHokySQ6z6WYK1CfK I+J/Zj6SAtlmiLjVwVjliJEfpDoTpq7r5xwl3QDUXLBjLp1E06DS9NdCEWaXxcGo4jiPaK SjcJ/OyK3utUGTpfidwUmhtRv8SRrtg= Received: by mail-qv1-f41.google.com with SMTP id 6a1803df08f44-696147fb5a7so8510996d6.0 for ; Thu, 28 Mar 2024 07:16:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1711635414; x=1712240214; 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=TZkkr+8BMbOQbcHkSO5h3H5iApjHoCs8BFl7+oRwVKE=; b=aCKcEelQsTRmm8tMehXkdliv5J6h61HMbdfu6YcLMpPUXvNWnK3QXmc3+Zsnj/F4LN 22jsplWEvC3pKGsOGEsqgj/TSMADxT+6m/hI5JTn2Jy4OIDbO+g5XOvBkScMQHCTvTDl owj+Ot1D7SC8x9RJGvgRprbn1D4i2TydlcPYg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711635414; x=1712240214; 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=TZkkr+8BMbOQbcHkSO5h3H5iApjHoCs8BFl7+oRwVKE=; b=Tm5DcPLCuNjuIbCDUkYZBC2fM+cDTnzzG4CaC6eeFF5gnqlajKfa8nXvWwzai2VxR6 vVyJ5ErxiS3d3+purUyjIxF+xw5eu7FA4kxF7DHV+QbczwKlLxATvAdBXDkUU/4bigFj BqK9Ps/jLi3Ozg3ci1nWmY507AXs6nhRrozSnBadYe2U+UnamQfpdJvmn9KS8oscJ7Wg Q6nS0EN/lVBSsWYa9mlde4kaM3sspnSjeWRO9OIs4Amy6YdGMuPRjrQtRLSpS4DTnYkE u+a9mT6qBGV7SkH0KsVJ+AsW8e00XXwmPal4qddCOj/EghsJYUencQxQHQr7Z7akla20 nYzg== X-Forwarded-Encrypted: i=1; AJvYcCW9q8BrzTa63lCW/mptUz90X1s7QK2lIHYp3N/JnsOtk81LZJXkLYbVssb0rP/gYbIXnOK/qi/SBlxaPS+B9Us3zUo= X-Gm-Message-State: AOJu0YzZmP6Dan2sOJL4eIbB9LqWCm3Z0VXxWfGOBg8OQtv3Vnt7MMiO j1eMGxnunIGMltlxsWR3HK9j/7mOSNW6A8E+AYpTk1+EzY2u/b2uRYspj/8bUxQjMi3FW8eOOS0 = X-Google-Smtp-Source: AGHT+IHsuKoJAS+Em+M5yIuW5lLOYfd8Lknm+Rv4mhcOY1wia7IgJexAbcHPQboiG9pmGkDXU2TNMw== X-Received: by 2002:a0c:df06:0:b0:690:d4e9:fc5b with SMTP id g6-20020a0cdf06000000b00690d4e9fc5bmr2241450qvl.27.1711635414492; Thu, 28 Mar 2024 07:16:54 -0700 (PDT) Received: from mail-qt1-f176.google.com (mail-qt1-f176.google.com. [209.85.160.176]) by smtp.gmail.com with ESMTPSA id jm15-20020ad45ecf000000b00690afbf56d5sm673357qvb.66.2024.03.28.07.16.54 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 28 Mar 2024 07:16:54 -0700 (PDT) Received: by mail-qt1-f176.google.com with SMTP id d75a77b69052e-428405a0205so342671cf.1 for ; Thu, 28 Mar 2024 07:16:54 -0700 (PDT) X-Forwarded-Encrypted: i=1; AJvYcCXuLPv4sErUCJuOsxi6EwfI0U98gAFG1l9NuDioZAh7wE8FjEA00nV01TUHKZbOAl8j437NyXYFQTPIdJb5dqqjvR8= X-Received: by 2002:a05:622a:608d:b0:431:6352:80fb with SMTP id hf13-20020a05622a608d00b00431635280fbmr244987qtb.16.1711635413584; Thu, 28 Mar 2024 07:16:53 -0700 (PDT) MIME-Version: 1.0 References: <20240205092626.v2.1.Id9ad163b60d21c9e56c2d686b0cc9083a8ba7924@changeid> In-Reply-To: From: Doug Anderson Date: Thu, 28 Mar 2024 07:16:37 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2] regset: use kvzalloc() for regset_get_alloc() To: Alexander Viro , Christian Brauner , Andrew Morton 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: rspam12 X-Rspamd-Queue-Id: 6B8D1140019 X-Stat-Signature: xejwnrhynr1ttms5hccmeyfbw6tjbw8c X-HE-Tag: 1711635415-928699 X-HE-Meta: U2FsdGVkX1+cXi3jv8peO2PzTSGNrPb9ftWxPoSu0QECHqxI20BFrz4C5LAkJF5z/FaBL8tLYD9EMMPCTBJVrMkn/nCGkzHYpomo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Xl9Xc++36Zdc1KuefDuSWQsco9YjelM1VqQ7IbsUjYFGQS1nTpph8ZRWgXpdCOx+NQ15DpgO92IOMwAv08zKXhA3CPGgpaLdwRePS+/FgHGU4i9b1xVcR8LJmTaFGjdhQwq5pvHxlBEGAg1TWvQQzJ4Y0azPhCGkdiasWoMOxt3X5pdYW3VQlo0BkwDF4eu6LZ41wYzP62T0tJf1jNeyO4N/nwP4WZK/MWLYHmhTxlBZ4e6hyio/ILKLP/SZjQgAB3zOQULMB1VJ5YKibQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Hi, On Mon, Feb 26, 2024 at 3:55=E2=80=AFPM Doug Anderson wrote: > > 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.Id9ad163b60d21c9e56c2d68= 6b0cc9083a8ba7924@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-= c7600ca74b9b@kernel.org I'm not trying to be a pest here, so if this is on someone's todo list and they'll get to it eventually then feel free to tell me to go away and I'll snooze this for another few months. I just want to make sure it's not forgotten. I've been assuming that someone like Al Viro or Christian Brauner would land this patch eventually and I know Al responded rather quickly to my v1 [2]. I think all of Al's issues were resolved by Mark Brown's patch [1] (which has landed in the arm64 tree) and my updating of the patch description in v2. I see that Al and Christian are flagged as maintainers of "fs/binfmt_elf.c" which is one of the two files I'm touching, so that's mostly why I was assuming they would land it. ...but I realize that perhaps my assumptions are wrong and this needs to go through a different maintainer. In this case (if I'm reading it correctly) Al and Christian are listed because the file is under "fs" even though this isn't _really_ much of a filesystem-related patch. Perhaps this needs to go through something like Andrew Morton's tree since he often picks up patches that have nowhere else to land? If someone else has suggestions, I'm all ears. I'm also happy to repost this patch in case it helps with a maintainer applying it. Thanks! -Doug [1] https://lore.kernel.org/r/20240213-arm64-sve-ptrace-regset-size-v2-1-c7= 600ca74b9b@kernel.org [2] https://lore.kernel.org/r/20240202012249.GU2087318@ZenIV/