On Wed, Jun 12, 2024 at 03:30:24PM -0700, Boqun Feng wrote: > In order to support LKMM atomics in Rust, add rust_helper_* for atomic > APIs. These helpers ensure the implementation of LKMM atomics in Rust is > the same as in C. This could save the maintenance burden of having two > similar atomic implementations in asm. > > Originally-by: Mark Rutland <mark.rutland@xxxxxxx> > Signed-off-by: Boqun Feng <boqun.feng@xxxxxxxxx> FWIW, I'm happy with the concept; I have a couple of minor comments below. > --- > rust/atomic_helpers.h | 1035 +++++++++++++++++++++ > rust/helpers.c | 2 + > scripts/atomic/gen-atomics.sh | 1 + > scripts/atomic/gen-rust-atomic-helpers.sh | 64 ++ > 4 files changed, 1102 insertions(+) > create mode 100644 rust/atomic_helpers.h > create mode 100755 scripts/atomic/gen-rust-atomic-helpers.sh [...] > +#gen_proto_order_variant(meta, pfx, name, sfx, order, atomic, int, raw, arg...) > +gen_proto_order_variant() > +{ > + local meta="$1"; shift > + local pfx="$1"; shift > + local name="$1"; shift > + local sfx="$1"; shift > + local order="$1"; shift > + local atomic="$1"; shift > + local int="$1"; shift > + local raw="$1"; shift > + local attrs="${raw:+noinstr }" You removed the 'raw_' atomic generation below, so you can drop the 'raw' parameter and the 'attrs' variable (both here and in the template)... > + local atomicname="${raw}${atomic}_${pfx}${name}${sfx}${order}" > + > + local ret="$(gen_ret_type "${meta}" "${int}")" > + local params="$(gen_params "${int}" "${atomic}" "$@")" > + local args="$(gen_args "$@")" > + local retstmt="$(gen_ret_stmt "${meta}")" > + > +cat <<EOF > +__rust_helper ${attrs}${ret} ... e.g. you can remove '${attrs}' here. [...] > +grep '^[a-z]' "$1" | while read name meta args; do > + gen_proto "${meta}" "${name}" "atomic" "int" "" ${args} > +done > + > +grep '^[a-z]' "$1" | while read name meta args; do > + gen_proto "${meta}" "${name}" "atomic64" "s64" "" ${args} > +done With the 'raw' parameter removed above, the '""' argument can be dropped. Any reason to not have the atomic_long_*() API? It seems like an odd ommision. Mark.