rust-for-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Gary Guo <gary@garyguo.net>
To: Andreas Hindborg <nmi@metaspace.dk>
Cc: "Miguel Ojeda" <ojeda@kernel.org>,
	"Alex Gaynor" <alex.gaynor@gmail.com>,
	"Wedson Almeida Filho" <wedsonaf@gmail.com>,
	"Masahiro Yamada" <masahiroy@kernel.org>,
	"Andreas Hindborg" <a.hindborg@samsung.com>,
	"Boqun Feng" <boqun.feng@gmail.com>,
	"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
	"Benno Lossin" <benno.lossin@proton.me>,
	"Alice Ryhl" <aliceryhl@google.com>,
	"Nathan Chancellor" <nathan@kernel.org>,
	"Nicolas Schier" <nicolas@fjasle.eu>,
	"Sergio González Collado" <sergio.collado@gmail.com>,
	rust-for-linux@vger.kernel.org, linux-kbuild@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3] kbuild: rust: split up helpers.c
Date: Sat, 17 Aug 2024 17:26:46 +0100	[thread overview]
Message-ID: <20240817172646.1ffc75bc.gary@garyguo.net> (raw)
In-Reply-To: <20240815103016.2771842-1-nmi@metaspace.dk>

On Thu, 15 Aug 2024 10:30:26 +0000
Andreas Hindborg <nmi@metaspace.dk> wrote:

> From: Andreas Hindborg <a.hindborg@samsung.com>
> 
> This patch splits up the rust helpers C file. When rebasing patch sets on
> upstream linux, merge conflicts in helpers.c is common and time consuming
> [1]. Thus, split the file so that each kernel component can live in a
> separate file.
> 
> This patch lists helper files explicitly and thus conflicts in the file
> list is still likely. However, they should be more simple to resolve than
> the conflicts usually seen in helpers.c.
> 
> Link: https://rust-for-linux.zulipchat.com/#narrow/stream/288089-General/topic/Splitting.20up.20helpers.2Ec/near/426694012 [1]
> Signed-off-by: Andreas Hindborg <a.hindborg@samsung.com>
> 
> ---
> 
> Changes since v2 [2]:
> - Rebase on 6.11-rc3.
> - Use `cpp` instead of Makefile scripting to concatenate files.
> 
> Link:
> https://lore.kernel.org/rust-for-linux/20240507210818.672517-1-ojeda@kernel.org/ [2]
> ---
>  rust/Makefile               |   6 +-
>  rust/helpers.c              | 239 ------------------------------------
>  rust/helpers/README.md      |  17 +++
>  rust/helpers/blk.c          |  16 +++
>  rust/helpers/bug.c          |   9 ++
>  rust/helpers/build_assert.c |  25 ++++
>  rust/helpers/build_bug.c    |  10 ++
>  rust/helpers/err.c          |  22 ++++
>  rust/helpers/helpers.c      |  18 +++
>  rust/helpers/kunit.c        |  10 ++
>  rust/helpers/mutex.c        |  10 ++
>  rust/helpers/page.c         |  24 ++++
>  rust/helpers/refcount.c     |  22 ++++
>  rust/helpers/signal.c       |  10 ++
>  rust/helpers/slab.c         |  10 ++
>  rust/helpers/spinlock.c     |  27 ++++
>  rust/helpers/task.c         |  22 ++++
>  rust/helpers/uaccess.c      |  17 +++
>  rust/helpers/wait.c         |  10 ++
>  rust/helpers/workqueue.c    |  16 +++
>  20 files changed, 298 insertions(+), 242 deletions(-)
>  delete mode 100644 rust/helpers.c
>  create mode 100644 rust/helpers/README.md
>  create mode 100644 rust/helpers/blk.c
>  create mode 100644 rust/helpers/bug.c
>  create mode 100644 rust/helpers/build_assert.c
>  create mode 100644 rust/helpers/build_bug.c
>  create mode 100644 rust/helpers/err.c
>  create mode 100644 rust/helpers/helpers.c
>  create mode 100644 rust/helpers/kunit.c
>  create mode 100644 rust/helpers/mutex.c
>  create mode 100644 rust/helpers/page.c
>  create mode 100644 rust/helpers/refcount.c
>  create mode 100644 rust/helpers/signal.c
>  create mode 100644 rust/helpers/slab.c
>  create mode 100644 rust/helpers/spinlock.c
>  create mode 100644 rust/helpers/task.c
>  create mode 100644 rust/helpers/uaccess.c
>  create mode 100644 rust/helpers/wait.c
>  create mode 100644 rust/helpers/workqueue.c
> 
> diff --git a/rust/helpers/page.c b/rust/helpers/page.c
> new file mode 100644
> index 000000000000..b3280c80b283
> --- /dev/null
> +++ b/rust/helpers/page.c
> @@ -0,0 +1,24 @@
> +// SPDX-License-Identifier: GPL-2.0
> +
> +#include <linux/gfp.h>
> +#include <linux/highmem.h>
> +
> +struct page *rust_helper_alloc_pages(gfp_t gfp_mask, unsigned int order)
> +{
> +	return alloc_pages(gfp_mask, order);
> +}
> +EXPORT_SYMBOL_GPL(rust_helper_alloc_pages);
> +
> +void *rust_helper_kmap_local_page(struct page *page)
> +{
> +	return kmap_local_page(page);
> +}
> +EXPORT_SYMBOL_GPL(rust_helper_kmap_local_page);
> +
> +void rust_helper_kunmap_local(const void *addr)
> +{
> +	kunmap_local(addr);
> +}
> +EXPORT_SYMBOL_GPL(rust_helper_kunmap_local);
> +
> +

nit: there're two trailing newlines at the end of this file.

Best,
Gary

> diff --git a/rust/helpers/refcount.c b/rust/helpers/refcount.c
> new file mode 100644
> index 000000000000..13ab64805f77
> --- /dev/null
> +++ b/rust/helpers/refcount.c
> @@ -0,0 +1,22 @@
> +// SPDX-License-Identifier: GPL-2.0
> +
> +#include <linux/export.h>
> +#include <linux/refcount.h>
> +
> +refcount_t rust_helper_REFCOUNT_INIT(int n)
> +{
> +	return (refcount_t)REFCOUNT_INIT(n);
> +}
> +EXPORT_SYMBOL_GPL(rust_helper_REFCOUNT_INIT);
> +
> +void rust_helper_refcount_inc(refcount_t *r)
> +{
> +	refcount_inc(r);
> +}
> +EXPORT_SYMBOL_GPL(rust_helper_refcount_inc);
> +
> +bool rust_helper_refcount_dec_and_test(refcount_t *r)
> +{
> +	return refcount_dec_and_test(r);
> +}
> +EXPORT_SYMBOL_GPL(rust_helper_refcount_dec_and_test);

  parent reply	other threads:[~2024-08-17 16:26 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-15 10:30 [PATCH v3] kbuild: rust: split up helpers.c Andreas Hindborg
2024-08-15 10:46 ` Miguel Ojeda
2024-08-15 11:36 ` Dirk Behme
2024-08-15 14:32 ` Benno Lossin
2024-08-15 18:23 ` Gary Guo
2024-08-16  8:40 ` Alice Ryhl
2024-08-17 16:26 ` Gary Guo [this message]
2024-08-18 21:33 ` Miguel Ojeda

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240817172646.1ffc75bc.gary@garyguo.net \
    --to=gary@garyguo.net \
    --cc=a.hindborg@samsung.com \
    --cc=alex.gaynor@gmail.com \
    --cc=aliceryhl@google.com \
    --cc=benno.lossin@proton.me \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun.feng@gmail.com \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=masahiroy@kernel.org \
    --cc=nathan@kernel.org \
    --cc=nicolas@fjasle.eu \
    --cc=nmi@metaspace.dk \
    --cc=ojeda@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=sergio.collado@gmail.com \
    --cc=wedsonaf@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).