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 E3FCCE77197 for ; Sun, 5 Jan 2025 13:01:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6EB086B0083; Sun, 5 Jan 2025 08:01:53 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 69AFE6B0088; Sun, 5 Jan 2025 08:01:53 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 53CB46B0089; Sun, 5 Jan 2025 08:01:53 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 328166B0083 for ; Sun, 5 Jan 2025 08:01:53 -0500 (EST) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id E4B71B0672 for ; Sun, 5 Jan 2025 13:01:52 +0000 (UTC) X-FDA: 82973410464.16.BFD8DCE Received: from mout01.posteo.de (mout01.posteo.de [185.67.36.65]) by imf21.hostedemail.com (Postfix) with ESMTP id E25D31C0021 for ; Sun, 5 Jan 2025 13:01:50 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=posteo.net header.s=2017 header.b=njpq4wpu; dmarc=pass (policy=none) header.from=posteo.net; spf=pass (imf21.hostedemail.com: domain of charmitro@posteo.net designates 185.67.36.65 as permitted sender) smtp.mailfrom=charmitro@posteo.net ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1736082111; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=QLvaDvFRDb3BpKxziz5tFYvPv0wt6Rsr9RinMJcZ1rw=; b=2vGtpnUp51RUPhaOkvGcaSL1imWgLZ2TJAPN8o1KEcXBBEnTyNL7TdJaxPUzKP/wplMocG wa+a+PniRjs9Fg2e+iGOkTrINWrbunbz1pgSgoKL1ItBjiWtCASDIjzZ2tNxXYxeogmhGQ 4qyEhO/52Qp2LS2BvrrM9TekHKKVuSg= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736082111; a=rsa-sha256; cv=none; b=lKBzOl/iEcHudxPvGdOxDoyYfWwutAI2rk+Xl3VhcOiZwWFaUnpd20j51MHMEGmJaH4J5b SwDBKoasP5a0N8asWQcwU+xU8hkDpIKSRxy3Ahhr9N4CvaKD/Bw9ORb91bpjzpTFYDto9t Olcw8HeYlr4Ow/RPw6+KLpSVi5AS8cM= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=posteo.net header.s=2017 header.b=njpq4wpu; dmarc=pass (policy=none) header.from=posteo.net; spf=pass (imf21.hostedemail.com: domain of charmitro@posteo.net designates 185.67.36.65 as permitted sender) smtp.mailfrom=charmitro@posteo.net Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id 560F7240027 for ; Sun, 5 Jan 2025 14:01:48 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1736082108; bh=cAZ/UVOmy3h5Edo8pBDzVhgjHgmybs8Cw4CcL0q7Kpg=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type: From; b=njpq4wpuau3Dgo0udc9Ae790xkCnYaqVQ3gbaNZHnVUNZww/dHOouTAftXB+7ijMK nxxWMl3BInJ0eRdtvhXGBTfBUPd1if03QmBbMKBlJjnWF/g9oxK9ged2vwpGXm6OyQ WKeVRL3IlCuR3Euuos2KUDVMgVFS8qf6fGjvBmb7ZbPncMQ5TTDvFGPyquy7aacvFS itzwjVKy3LBQmZCcF5C8pMXPX1GGMHBklbHhahwmd/Mhyv/h88ViHY+YJgfz3eoejt tseI2DVtZh8hUCwKbrm/583Dla9wRQrLP771Nit3nSR/fxTT+OHybv8cUq0xq39S66 oitoV4ZGsPzJA== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4YQyBJ47Wjz6tvl; Sun, 5 Jan 2025 14:01:44 +0100 (CET) From: Charalampos Mitrodimas To: "Christoph Lameter (Ampere)" Cc: Mitchell Levy , 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: <5374de79-0ee6-e817-0f87-c800a6fbb733@gentwo.org> (Christoph Lameter's message of "Fri, 20 Dec 2024 09:56:54 -0800 (PST)") References: <20241219-rust-percpu-v1-0-209117e822b1@gmail.com> <20241219-rust-percpu-v1-3-209117e822b1@gmail.com> <5374de79-0ee6-e817-0f87-c800a6fbb733@gentwo.org> Date: Sun, 05 Jan 2025 13:01:43 +0000 Message-ID: MIME-Version: 1.0 Content-Type: text/plain X-Stat-Signature: 8qbpk78gjghbnkyn98566ex5b1559gue X-Rspamd-Queue-Id: E25D31C0021 X-Rspam-User: X-Rspamd-Server: rspam01 X-HE-Tag: 1736082110-628584 X-HE-Meta: U2FsdGVkX184vU0byRG8JBk9cgFoTFN+0J/ghDFOspu/TTXEyi8nCmVhSYK2sU9m5gyay1PK357IqP1bW2732UJF/CeWL+A6P4r6LeXlaRawSXmdDe5ife64QCfRyXmoLpuCzk70IRck3Fj9z9SMGgR3uA3aGt7JsimPWvDVDRSO5Tj3Rtdkxdjxlg6J4Quuuy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nvcMBUjrca+loLf8vv+nRwIiof+aDbL60PfQpFLUiTK4XgRY0KBlJnPIiwt06EvrSgNiobNaIqO9gzW4MNBouk+CJSijaQmI8oSY9mDdj78hp9C0OFxhGuIH3lO/7oPpY= X-Bogosity: Unsure, tests=bogofilter, spamicity=0.499530, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: "Christoph Lameter (Ampere)" writes: > On Thu, 19 Dec 2024, Mitchell Levy wrote: > >> + let mut native: i64 = 0; >> + let mut pcpu: PerCpuRef = 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()) } > >> + native += -1; >> + *pcpu += -1; >> + assert!(native == *pcpu && native == -1); >> + >> + native += 1; >> + *pcpu += 1; >> + assert!(native == *pcpu && native == 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);