From: Jens Axboe <axboe@kernel.dk>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] task_work: cleanup notification modes
Date: Fri, 16 Oct 2020 16:39:47 -0600 [thread overview]
Message-ID: <aaed79d1-972f-e4bd-f3ac-d589cd729163@kernel.dk> (raw)
In-Reply-To: <87tuutalre.fsf@nanos.tec.linutronix.de>
On 10/16/20 3:44 PM, Thomas Gleixner wrote:
> On Fri, Oct 16 2020 at 09:16, Jens Axboe wrote:
>> A previous commit changed the notification mode from 0/1 to allowing
>
> No. It changed it from boolean to an int.
>
> There is a fundamental difference between 0/1 and false/true simply
> because it's a compiler implementation detail how to represent a boolean
> value.
>
> Assume the following:
>
> #define BAZ 0x08
>
> task_work_add(tsk, &work, foo & BAZ);
>
> So with a function signature of
>
> task_work_add(*tsk, *work, bool signal);
>
> the above 'foo & BAZ' becomes either true of false.
>
> With the changed function signature of
>
> task_work_add(*tsk, *work, int signal);
>
> the above becomes the result of 'foo & BAZ' which means that this
> construct will not longer do the right thing.
>
> It's pure luck that none of the usage sites relied on the boolean
> property of that argument.
It wasn't pure luck, that was checked before that change was made. No
users did anything funky, it was all false/true or 0/1.
> Please spell it out correctly that converting a boolean argument to an
> integer argument is not equivalent.
Fixed up the commit message to be more descriptive.
>> switch (notify) {
>> + case TWA_NONE:
>> + break;
>> case TWA_RESUME:
>> set_notify_resume(task);
>> break;
>
> The enum will not prevent that either and what you really want to do is
> to have some form of debug warning if 'notify' is out of range, which
> would have been the right thing to do in the first place.
I added a WARN_ON_ONCE() in the default case for that one.
>> - * @notify: send the notification if true
>> + * @notify: send chosen notification, if any
>
> Is that really all you found to be wrong in that comment?
There really is nothing wrong, but it's not very descriptive (wasn't
before either). I've added a fuller description of the various TWA_*
notification types now.
--
Jens Axboe
next prev parent reply other threads:[~2020-10-16 22:39 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-16 15:16 [PATCH] task_work: cleanup notification modes Jens Axboe
2020-10-16 21:44 ` Thomas Gleixner
2020-10-16 22:39 ` Jens Axboe [this message]
2020-10-16 23:09 ` Thomas Gleixner
2020-10-16 23:13 ` Jens Axboe
2020-10-16 23:38 ` Thomas Gleixner
2020-10-16 23:43 ` Jens Axboe
2020-10-17 15:31 ` Thomas Gleixner
2020-10-17 15:36 ` Jens Axboe
2020-10-17 20:18 ` Thomas Gleixner
2020-10-17 20:32 ` Jens Axboe
2020-10-17 21:01 ` Thomas Gleixner
2020-10-17 21:03 ` Jens Axboe
2020-10-17 21:17 ` Thomas Gleixner
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=aaed79d1-972f-e4bd-f3ac-d589cd729163@kernel.dk \
--to=axboe@kernel.dk \
--cc=linux-kernel@vger.kernel.org \
--cc=tglx@linutronix.de \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.