rust-for-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Wedson Almeida Filho <wedsonaf@google.com>
To: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
Cc: Finn Behrens <me@kloenk.de>, rust-for-linux@vger.kernel.org
Subject: Re: module as seperate crate
Date: Sat, 12 Dec 2020 23:48:33 +0000	[thread overview]
Message-ID: <CAMKQLNJKZ+z985+zB0WJ+fiQkLT-q_bNrYH_qvh_xPDcQuiDyw@mail.gmail.com> (raw)
In-Reply-To: <CANiq72mfzkVVV+zV-GRWo+kTh=b3VayPz-9Bk+Yn35YuusDEQA@mail.gmail.com>

Thank you, Miguel!

Finn,

I posted on your PR before, but I think this is a better forum for
this. IIUC, you are implementing the pr_* family of functions and you
need a mutex for that. If this is the case, I think using a mutex is
probably not the ideal solution because it precludes the functions
from being used in contexts where blocking the task is not allowed.

I've just uploaded[1] a WIP commit that contains a SpinLock, which is
probably a better choice. Also, if this is a one-time initialisation
sort of thing, we can probably use a more efficient synchronisation
primitive. If you could describe your needs in more detail we could
probably work something out.

(As for the SpinLock implementation, it also has a condition variable
that uses a generic `Guard`, so if you want to hook your mutex
implementation to this, it will automatically work with the condition
variable too.)

Cheers,
-Wedson

[1] Spin lock commit:
https://github.com/Rust-for-Linux/linux/commit/3a9b3137f6fd179df3dacb72d717f5f4b4d0a266

On Wed, 9 Dec 2020 at 23:20, Miguel Ojeda
<miguel.ojeda.sandonis@gmail.com> wrote:
>
> On Sun, Nov 29, 2020 at 7:30 PM Finn Behrens <me@kloenk.de> wrote:
> >
> > I create a static mut Mutex<&str> (or similar) to contain the pr_fmt
> > string. I cannot init the mutex in a const fn, and so I cannot create an
> > static mut value which already contains a mutex. So I have to call an
> > init_printk functions which creates this mutex. That's all what I'm doing.
> >
> > Will try to get something working the following days, and then send a
> > patch. Mayebe easier to decide then.
>
> This email is just to give Wedson an email thread to reply to. :-)
>
> Cheers,
> Miguel

  reply	other threads:[~2020-12-12 23:49 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-29 17:36 module as seperate crate Finn Behrens
2020-11-29 17:51 ` Miguel Ojeda
2020-11-29 17:54   ` Finn Behrens
     [not found]     ` <d417fec0-c5c6-edda-796e-a861f5518eed@kloenk.de>
     [not found]       ` <CANiq72negqN+2eOjieYW1Zas1ays3t3W-+wZisXjF9q=kob3yw@mail.gmail.com>
2020-11-29 18:30         ` Finn Behrens
2020-12-09 23:20           ` Miguel Ojeda
2020-12-12 23:48             ` Wedson Almeida Filho [this message]
2020-12-13  1:00               ` 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=CAMKQLNJKZ+z985+zB0WJ+fiQkLT-q_bNrYH_qvh_xPDcQuiDyw@mail.gmail.com \
    --to=wedsonaf@google.com \
    --cc=me@kloenk.de \
    --cc=miguel.ojeda.sandonis@gmail.com \
    --cc=rust-for-linux@vger.kernel.org \
    /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).