Re: [PATCH bpf-next v3 2/7] mm/percpu.c: introduce pcpu_alloc_size()

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

 



On Fri, Oct 20, 2023 at 11:03 AM Dennis Zhou <dennis@xxxxxxxxxx> wrote:
>
> On Fri, Oct 20, 2023 at 10:58:37AM -0700, Alexei Starovoitov wrote:
> > On Fri, Oct 20, 2023 at 10:48 AM Dennis Zhou <dennis@xxxxxxxxxx> wrote:
> > >
> > > On Fri, Oct 20, 2023 at 09:31:57PM +0800, Hou Tao wrote:
> > > > From: Hou Tao <houtao1@xxxxxxxxxx>
> > > >
> > > > Introduce pcpu_alloc_size() to get the size of the dynamic per-cpu
> > > > area. It will be used by bpf memory allocator in the following patches.
> > > > BPF memory allocator maintains per-cpu area caches for multiple area
> > > > sizes and its free API only has the to-be-freed per-cpu pointer, so it
> > > > needs the size of dynamic per-cpu area to select the corresponding cache
> > > > when bpf program frees the dynamic per-cpu pointer.
> > > >
> > > > Acked-by: Dennis Zhou <dennis@xxxxxxxxxx>
> > > > Signed-off-by: Hou Tao <houtao1@xxxxxxxxxx>
> > > > ---
> > > >  include/linux/percpu.h |  1 +
> > > >  mm/percpu.c            | 31 +++++++++++++++++++++++++++++++
> > > >  2 files changed, 32 insertions(+)
> > > >
> > > > diff --git a/include/linux/percpu.h b/include/linux/percpu.h
> > > > index 68fac2e7cbe67..8c677f185901b 100644
> > > > --- a/include/linux/percpu.h
> > > > +++ b/include/linux/percpu.h
> > > > @@ -132,6 +132,7 @@ extern void __init setup_per_cpu_areas(void);
> > > >  extern void __percpu *__alloc_percpu_gfp(size_t size, size_t align, gfp_t gfp) __alloc_size(1);
> > > >  extern void __percpu *__alloc_percpu(size_t size, size_t align) __alloc_size(1);
> > > >  extern void free_percpu(void __percpu *__pdata);
> > > > +extern size_t pcpu_alloc_size(void __percpu *__pdata);
> > > >
> > > >  DEFINE_FREE(free_percpu, void __percpu *, free_percpu(_T))
> > > >
> > > > diff --git a/mm/percpu.c b/mm/percpu.c
> > > > index 76b9c5e63c562..1759b91c8944a 100644
> > > > --- a/mm/percpu.c
> > > > +++ b/mm/percpu.c
> > > > @@ -2244,6 +2244,37 @@ static void pcpu_balance_workfn(struct work_struct *work)
> > > >       mutex_unlock(&pcpu_alloc_mutex);
> > > >  }
> > > >
> > > > +/**
> > > > + * pcpu_alloc_size - the size of the dynamic percpu area
> > > > + * @ptr: pointer to the dynamic percpu area
> > > > + *
> > > > + * Returns the size of the @ptr allocation. This is undefined for statically
> > >                                               ^
> > >
> > > Nit: Alexei, when you pull this, can you make it a double space here?
> > > Just keeps percpu's file consistent.
> >
> > Argh. Already applied.
> > That's a very weird style you have in a few places.
> > $ grep '\.  [A-z]' mm/*.c|wc -l
> > 1118
> > $ grep '\. [A-z]' mm/*.c|wc -l
> > 2451
> >
> > Single space is used more often in mm/* and in the rest of the kernel.
> >
> > $ grep '\. [A-z]' mm/percpu.c|wc -l
> > 10
> >
> > percpu.c isn't consistent either.
> >
> > I can force push if you really insist.
>
> Eh, if it's trouble I can fix it in the future. I know single space is
> more common, but percpu was written with double so I'm trying my best to
> keep the file consistent.

Ok. Fair enough.
Force pushed with double space.





[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux