Re: [PATCH RFC 3/3] rust: percpu: add a rust per-CPU variable test

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Dec 20, 2024 at 09:56:54AM -0800, Christoph Lameter (Ampere) wrote:
> On Thu, 19 Dec 2024, Mitchell Levy wrote:
> 
> > +        let mut native: i64 = 0;
> > +        let mut pcpu: PerCpuRef<i64> = unsafe { unsafe_get_per_cpu_ref!(PERCPU, CpuGuard::new()) };
> 
> A bit complex.
> 
> > +        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?
> 

FWIW, there is a declare_extern_per_cpu!() marco in patch #1, and
Mitchell used it to access this_cpu_off (defined in C).

Maybe we want to see an example here?

Regards,
Boqun

> How do you go about using per cpu atomics like
> 
> this_cpu_inc(nr_dentry_unused);
> 
> 




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux