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 33751E77188 for ; Wed, 8 Jan 2025 16:18:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BC4846B0096; Wed, 8 Jan 2025 11:18:11 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B74FE6B0098; Wed, 8 Jan 2025 11:18:11 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A3BC36B0099; Wed, 8 Jan 2025 11:18:11 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 84C7D6B0096 for ; Wed, 8 Jan 2025 11:18:11 -0500 (EST) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id D8D7D1C8539 for ; Wed, 8 Jan 2025 16:18:08 +0000 (UTC) X-FDA: 82984791456.17.E97AC4C Received: from mout01.posteo.de (mout01.posteo.de [185.67.36.65]) by imf19.hostedemail.com (Postfix) with ESMTP id ACA271A0017 for ; Wed, 8 Jan 2025 16:18:06 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=posteo.net header.s=2017 header.b=Ga1KgKed; spf=pass (imf19.hostedemail.com: domain of charmitro@posteo.net designates 185.67.36.65 as permitted sender) smtp.mailfrom=charmitro@posteo.net; dmarc=pass (policy=none) header.from=posteo.net ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1736353087; 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=2V9+HkCu0IFReo85DyV5JE6gUVxL4DWwMTfUqJVYJtM=; b=dA/fgT2FlssvOHh4AVeNI9/BGlrDRg3AQSEir1XWf9MIT5nUldW4hYNKYqIz5xsa7DF5n8 Bc8G+Gm6jOzfgg8ZScvhspCKUJ1MMgE8cwPR4tDhCAbmvXkIVBqmvNgDmxAHUY/Nu9wCcQ DxhZys+Nc0kogy2kiguA9hREkGDVCyM= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=posteo.net header.s=2017 header.b=Ga1KgKed; spf=pass (imf19.hostedemail.com: domain of charmitro@posteo.net designates 185.67.36.65 as permitted sender) smtp.mailfrom=charmitro@posteo.net; dmarc=pass (policy=none) header.from=posteo.net ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736353087; a=rsa-sha256; cv=none; b=HwVof1qZqkfwTxAeLBHf6KBrDPUEDwXehhOtLPtmsEwbZudP74zdZvvDBAW8oxURnaIYsS wT2lyR3K3IaLM8pYafU8G6D5l0ZR0D39zK3lVEaiqRujv5jjE2gtW5HCpM9g4a4TsF875c Byotzfd78wH9A9j0sag+6b57deLZbys= Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id B111C240028 for ; Wed, 8 Jan 2025 17:18:04 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1736353084; bh=yOBTlREGRBXDTsdlin8J4+t1EBnrYEjknmCFwqhiMZY=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type: Content-Transfer-Encoding:From; b=Ga1KgKedY8HcP2agEg1eZ9ve25yMVhRLpBTlr/tDunnLBKaYlrct502FQ71NrRWCB HrLBoJlxuRyrZ2LK1rA8z5kzS4ssjrVoyLTuRqaXhXzKkxuN14U9fZSTFCFbWFpSN6 N3izrUNjbQ8rT+HRcaZXnLvGJ9I9i+ohbSZq4+MESvdE3CkKhtMURJrpXdIOpw4hlt 18iB+r3/NXbUs7S0sTyxewZSpajHq7WbygK2aLo0ypEIY9xgABgQpgw5bJ+TWvEQEi p+1hIB+GqmCvdzjFPa1xyTapPPSv1kAfeQzSHu45BYOhji6kVvqFDPVz51vBVl9RaE fpggCx4h6XMlQ== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4YStPP4121z9rxR; Wed, 8 Jan 2025 17:18:01 +0100 (CET) From: Charalampos Mitrodimas To: Mitchell Levy Cc: "Christoph Lameter (Ampere)" , Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?utf-8?Q?Bj=C3=B6?= =?utf-8?Q?rn?= Roy Baron , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , Andrew Morton , Dennis Zhou , Tejun Heo , linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH RFC 3/3] rust: percpu: add a rust per-CPU variable test In-Reply-To: <677dbbb1.050a0220.39ba68.8825@mx.google.com> (Mitchell Levy's message of "Tue, 7 Jan 2025 15:41:28 -0800") References: <20241219-rust-percpu-v1-0-209117e822b1@gmail.com> <20241219-rust-percpu-v1-3-209117e822b1@gmail.com> <5374de79-0ee6-e817-0f87-c800a6fbb733@gentwo.org> <677dbbb1.050a0220.39ba68.8825@mx.google.com> Date: Wed, 08 Jan 2025 16:18:00 +0000 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: ACA271A0017 X-Rspam-User: X-Stat-Signature: tdm4abkychfahad4udaqq3miqqheuptr X-HE-Tag: 1736353086-917874 X-HE-Meta: U2FsdGVkX19lJ9HywbCtZdc963YJRNRoduZp17aQwg0ntxeMnmvyBOaG3FKOKZ5TGbNdpoYJtllqHjTiGJ/w5UTlG2semuLB4qYRjneOs6XBHC2dvTCx/7lkZc0kloi0iUo0R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Oz2cQ5gXU6sDtsAa240dxBVPCXwAH1Jem3CKSZmLu7C7HsqT0l8DpOWYArvttMegVQyMBE3OjwT4bTDe628zHtXF2+AykzwsqHTN9PxmbcYfpXtBGLUy1FgFyhqXXI0zDyopiTlKWQmGvJMCIjjNkznqqevq/M/L51xIAEUg8DpH2ynfcKl4t8yNodaqPRNq4rT6rVPj1NoafqWeRg6SElrbAhkhMV1otaTABB1Pc8X4te7OGjlbeu/DdHR3St47TVTFAqBYTTSt7E3Cd3C+40L8c6Fh9/ X-Bogosity: Unsure, tests=bogofilter, spamicity=0.499662, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Mitchell Levy writes: > On Sun, Jan 05, 2025 at 01:01:43PM +0000, Charalampos Mitrodimas wrote: >> "Christoph Lameter (Ampere)" writes: >> >> > On Thu, 19 Dec 2024, Mitchell Levy wrote: >> > >> >> + let mut native: i64 =3D 0; >> >> + let mut pcpu: PerCpuRef =3D unsafe { unsafe_get_per_cpu= _ref!(PERCPU, CpuGuard::new()) }; >> > >> > A bit complex. >> >> I agree with this, maybe a helper function would suffise? Something in >> terms of, >> unsafe fn get_per_cpu(var: &PerCpuVariable) -> PerCpuRef { >> unsafe_get_per_cpu_ref!(var, CpuGuard::new()) >> } > > I'm certainly open to adding such a helper. Is the main concern here the > unwieldy name? Generally, I prefer to keep modifications to global state > (disabling preemption via CpuGuard::new()) as explicit as possible, but > if there's consensus to the contrary, I'm happy to roll it into the > macro/a helper function. Yes, in my opinion, the macro name is indeed complex. You're right about keeping modifications as explicit as possible. A helper wouldn=E2=80=99t be necessary if the macro name were simpler. Is adding "unsafe_" to a macro that is unsafe a standard practice? Maybe we can remove it from the macro name. Documentation is enough IMO. > >> > >> >> + native +=3D -1; >> >> + *pcpu +=3D -1; >> >> + assert!(native =3D=3D *pcpu && native =3D=3D -1); >> >> + >> >> + native +=3D 1; >> >> + *pcpu +=3D 1; >> >> + assert!(native =3D=3D *pcpu && native =3D=3D 0); >> >> + >> > >> > That's pretty straightforward..... But is there no symbolic access to = the >> > per cpu namespace? How would you access the kernel per cpu variables >> > defined in C? >> > >> > How do you go about using per cpu atomics like >> > >> > this_cpu_inc(nr_dentry_unused);