Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp998565rdb; Fri, 2 Feb 2024 10:08:17 -0800 (PST) X-Google-Smtp-Source: AGHT+IGiVbxpqxriS+1mwUGAR0lFSgEXPOeLtSDSDJDzPSf4c048pytWMG/juUZhGwxqA2ZpvQ5w X-Received: by 2002:a2e:a607:0:b0:2d0:73dd:d125 with SMTP id v7-20020a2ea607000000b002d073ddd125mr3664538ljp.3.1706897297720; Fri, 02 Feb 2024 10:08:17 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706897297; cv=pass; d=google.com; s=arc-20160816; b=tjEPFiqOmn/9+Qy7RqjeYE8ykTOtueRW2kGmGHeaHE7ztpdKlcciqqNldg3S49JSeO 5lG4xQxjqOqaJGh2wS60wqnyk3fUGPxH4rDtNSpW5Gt4HMfHnCR7LI2WE9P1pqUtaJ/h 423j3ejTmYn0hMPL5Ov0fqGITunL1l5rEwpMMqlxEAZ4wU3YO9PKVVB385akZZfvZuaM vJiqYPs/KF3nc9icofyrl+sZPuIg0GsfWxbrx27oGPVLLH3UVwkyow5jcPwzqrUQoxgW kXy/u0uNWlprMTRxlczUGLb2BCoIGREtlY5WNo07bt3S0YpTF7IupWjVSNMcuoZzPGNi gkKw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date; bh=wGy05C5oPg9tAeMiSDJpni49gJ7juQnAyV0u/0GpgmY=; fh=nn45D6ILVgvYLrzcZoQ7E/MnKRs1mPFhzGoEDbqTE7M=; b=dLgWp47J1GNp8bj5/fRkwDWXWtvquPIVBTSsFrkU9+A+M4ZdObFaV0l4RS8Ht4Z3EK t2TyfqY6sb3f+Kb1whAKQcD6ffCs/sfJogqDDmCWKOYyjiU3sch7Tk7t7D4ZzZVStQZN vfVL9jUBcAwPetADimjQ98D3Gk+2KbtZ4QEbU/KZAaejzrLzjF5OKiQmUS8q7lwbmcoN 2FetzMg57k9+pjSjBjGWCyorMUNv+n4zFBu7XcDm6YPAqwDWKxJH4AoQEw3QBYOyd5AZ Ii8NyKmVlp5nZDul4KUB8KlHuvqp/Wmg5kpkL8y7xA1to4dWFntqcnepJ2wdh42JY9LS 9HMQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-50296-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50296-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com X-Forwarded-Encrypted: i=1; AJvYcCVZ2J5F6YWAy+FG9w37Ev5fvR8yZUHKkd3WtKtQRh7RNjrf1ePSN/RDDxLbntHiEhhpyAR8LyXxexZCvphlvhSHEhqnrVLXGDktDfVl8Q== Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id y42-20020a50bb2d000000b0055ef64fe00esi1052428ede.675.2024.02.02.10.08.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 10:08:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-50296-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-50296-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50296-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com 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 am.mirrors.kernel.org (Postfix) with ESMTPS id 76C291F25177 for ; Fri, 2 Feb 2024 18:08:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6583D14D44E; Fri, 2 Feb 2024 18:08:07 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BFE4E14C598; Fri, 2 Feb 2024 18:08:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706897286; cv=none; b=ImgoTBOYcQ3fG94ufq4GN5Ad2JBiPm/zz6YZtv1HURte4x1jKhIzecJCT7ekvvKXEK5xRQPlP1Wk1OcetbRupGZarBawFk6UnOqlwOK2kqMGJmXhZldrIQnJU1A07rPoRsXvqpzxfHwLxvxJIp524ZY6aIkoUU7mJkRvtCpZ4gY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706897286; c=relaxed/simple; bh=9rwlNwy8wTSVXhT4XMjY34L+K/gYaFA32HXn/coWBE4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=brlpoNJszZ5cpPiy1f/58GCmp3/WAQOsOyLEsR850sj1IvX3boKknCsna7ZsW/EIUSkWvtXZtvwh2DTdLyGn5IUDkadk5lwameNZy8AzqpO4rzkBg3CHyNpqGPw/+WJA+xrnxTODpVx0hLjln5gGPlwpXFioKZnPatrZjdt64Ps= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 748E119F0; Fri, 2 Feb 2024 10:08:41 -0800 (PST) Received: from e133380.arm.com (e133380.arm.com [10.1.197.58]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 37B2C3F762; Fri, 2 Feb 2024 10:07:57 -0800 (PST) Date: Fri, 2 Feb 2024 18:07:54 +0000 From: Dave Martin To: Al Viro Cc: Doug Anderson , Christian Brauner , Eric Biederman , Jan Kara , Kees Cook , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Oleg Nesterov , Catalin Marinas , Will Deacon , Mark Brown , Linux ARM Subject: Re: [PATCH] regset: use vmalloc() for regset_get_alloc() Message-ID: References: <20240201171159.1.Id9ad163b60d21c9e56c2d686b0cc9083a8ba7924@changeid> <20240202012249.GU2087318@ZenIV> <20240202030438.GV2087318@ZenIV> <20240202034925.GW2087318@ZenIV> <20240202040503.GX2087318@ZenIV> <20240202164947.GC2087318@ZenIV> <20240202165524.GD2087318@ZenIV> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240202165524.GD2087318@ZenIV> On Fri, Feb 02, 2024 at 04:55:24PM +0000, Al Viro wrote: > On Fri, Feb 02, 2024 at 04:49:47PM +0000, Al Viro wrote: > > > +folks from `./scripts/get_maintainer.pl -f arch/arm64/kernel/ptrace.c` > > > > > > Trying to follow the macros to see where "n" comes from is a maze of > > > twisty little passages, all alike. Hopefully someone from the ARM > > > world can help tell if the value of 17474 for n here is correct or if > > > something is wonky. Nope, that's the "correct" answer... > > > > It might be interesting to have it print the return value of __regset_get() > > in those cases; if *that* is huge, we really have a problem. If it ends up > > small enough to fit into few pages, OTOH... > > > > SVE_VQ_MAX is defined as 255; is that really in units of 128 bits? IOW, > > do we really expect to support 32Kbit registers? That would drive the > > size into that range, all right, but it would really suck on context > > switches. > > > > I could be misreading it, though - the macros in there are not easy to > > follow and I've never dealt with SVE before, so take the above with > > a cartload of salt. > > Worse - it's SVE_VQ_MAX is 512; sorry about the confusion. OK, that would > certainly explain the size (header + 32 registers, each up to 512 * 16 bytes), > but... ouch. Mark Brown [+ Cc] has been taking care of SVE in my absence, but from memory: The SVE architecture has a really big maximum vector size (16 * 128 = 2048 bits), and there is a theoretical possibility of it getting bigger in the future, though unlikely. Real platforms to date have a much smaller limit, though Qemu can go up to 2048 bits IIUC. My aim when working on the ABI was to future-proof it against foreseeable expansion on the architecture side, but this does mean that we cannot statically determine a sane limit for the vector size. I suppose we could have had a more sane limit built into the kernel or a Kconfig option for it, but it seemed simpler just to determine the size dynamically depending on the task's current state. This is not so important for coredumps, but for the the gdbstub wire protocol etc. it seemed undesirable to have the regset larger than needed. Hence the reason for adding ->get_size() in 27e64b4be4b8 ("regset: Add support for dynamically sized regsets"). What I guess was not so obvious from the commit message is the expected relationship between the actual and maximum possible size of the regset: for SVE the actual size is in practice going to be *much* smaller than the max, while the max is crazy large because of being an ABI design limit chosen for futureproofing purposes. So, if the only reason for trying to migrate to vmalloc() is to cope with an insanely sized regset on arm64, I think somehow or other we can avoid that. Options: a) bring back ->get_size() so that we can allocate the correct size before generating the regset data; b) make aarch64_regsets[] __ro_after_init and set aarch64_regsets[REGSET_SVE].n based on the boot-time probed maximum size (which will be sane); or c) allow membufs to grow if needed (sounds fragile though, and may be hard to justify just for one arch?). Thoughts? If people don't want to bring back get_size(), then (b) doesn't look too bad. Cheers ---Dave