Messages in this thread | | | From | Guo Ren <> | Date | Fri, 4 Aug 2023 10:29:30 +0800 | Subject | Re: [RFC PATCH v2 0/3] Deduplicate RISCV cmpxchg.h and atomic.c macros |
| |
On Fri, Aug 4, 2023 at 10:20 AM Leonardo Bras Soares Passos <leobras@redhat.com> wrote: > > On Thu, Aug 3, 2023 at 9:53 PM Guo Ren <guoren@kernel.org> wrote: > > > > On Thu, Aug 3, 2023 at 1:14 PM Leonardo Bras <leobras@redhat.com> wrote: > > > > > > I unified previous patchsets into a single one, since the work is related. > > > > > > While studying riscv's cmpxchg.h file, I got really interested in > > > understanding how RISCV asm implemented the different versions of > > > {cmp,}xchg. > > > > > > When I understood the pattern, it made sense for me to remove the > > > duplications and create macros to make it easier to understand what exactly > > > changes between the versions: Instruction sufixes & barriers. > > > > > > Also, did the same kind of work on atomic.c. > > > > > > Note to Guo Ren: > > > I did some further improvement after your previous reviews, so I ended > > > up afraid including your Reviewed-by before cheching if the changes are > > > ok for you. Please check it out again, I just removed some helper macros > > > that were not being used elsewhere in the kernel. > > I found this optimization has conflicts with the below patches: > > https://lore.kernel.org/linux-riscv/20230802164701.192791-15-guoren@kernel.org/ > > https://lore.kernel.org/linux-riscv/20230802164701.192791-5-guoren@kernel.org/ > > > > If yours merged, how do we support the inline cmpxchg/xchg_small > > function? > > Oh, I actually introduced my series so I could introduce new xchg and > cmpxchg for size 1 and 2. Is that what your patches are about, right? > > I was working on that yesterday, and decided to send the patchset > without them because I was still not sure enough. > > About implementation strategy, I was introducing a new macros for xchg > & cmpxchg with asm which would work for both for size 1 & size 2, and > use the switch-case to create the mask and and_value. > > You think that works enough? Good, go ahead.
> > > It's very struggling to use macros to implement complex > > functions. > > I agree, but with this we can achieve more generic code, which makes > more clear what is the pattern for given function. > > > Could you consider a more relaxed optimization in which we could > > insert inline cmpxchg/xchg_small? > > What about this: I finish the patches I have been working with > (cmpxchg & xchg for sizes 1 and 2), and if they are fine we expand > this patchset with them. If not, I try relaxing them a little so we > can merge with your set. > > Does that work for you? Great, you could provide cmpxchg & xchg for sizes 1 and 2, then my patch series would base on yours. After tested, I would give you Tested-by. > > Best regards, > Leo > > > > > > > > > > Thanks! > > > Leo > > > > > > > > > Changes since squashed cmpxchg: > > > - Unified with atomic.c patchset > > > - Rebased on top of torvalds/master (thanks Andrea Parri!) > > > - Removed helper macros that were not being used elsewhere in the kernel. > > > > > > Changes since (cmpxchg) RFCv3: > > > - Squashed the 6 original patches in 2: one for cmpxchg and one for xchg > > > https://lore.kernel.org/all/20230404163741.2762165-1-leobras@redhat.com/ > > > > > > Changes since (cmpxchg) RFCv2: > > > - Fixed macros that depend on having a local variable with a magic name > > > - Previous cast to (long) is now only applied on 4-bytes cmpxchg > > > https://lore.kernel.org/all/20230321074249.2221674-1-leobras@redhat.com/ > > > > > > Changes since (cmpxchg) RFCv1: > > > - Fixed patch 4/6 suffix from 'w.aqrl' to '.w.aqrl', to avoid build error > > > https://lore.kernel.org/all/20230318080059.1109286-1-leobras@redhat.com/ > > > > > > > > > Leonardo Bras (3): > > > riscv/cmpxchg: Deduplicate xchg() asm functions > > > riscv/cmpxchg: Deduplicate cmpxchg() asm and macros > > > riscv/atomic.h : Deduplicate arch_atomic.* > > > > > > arch/riscv/include/asm/atomic.h | 164 ++++++++-------- > > > arch/riscv/include/asm/cmpxchg.h | 318 +++++-------------------------- > > > 2 files changed, 123 insertions(+), 359 deletions(-) > > > > > > -- > > > 2.41.0 > > > > > > > > > -- > > Best Regards > > Guo Ren > > >
-- Best Regards Guo Ren
| |