From: Nathan Lynch <nathanl@linux.ibm.com>
To: Christophe Leroy <christophe.leroy@csgroup.eu>,
linuxppc-dev@lists.ozlabs.org
Cc: tyreld@linux.ibm.com, cheloha@linux.ibm.com, ldufour@linux.ibm.com
Subject: Re: [PATCH v2] powerpc/pseries: explicitly reschedule during drmem_lmb list traversal
Date: Wed, 12 Aug 2020 08:46:10 -0500 [thread overview]
Message-ID: <878sekyo2l.fsf@linux.ibm.com> (raw)
In-Reply-To: <c39976ce-a95c-a9cb-d119-d272b8de2f28@csgroup.eu>
Hi Christophe,
Christophe Leroy <christophe.leroy@csgroup.eu> writes:
>> +static inline struct drmem_lmb *drmem_lmb_next(struct drmem_lmb *lmb)
>> +{
>> + const unsigned int resched_interval = 20;
>> +
>> + BUG_ON(lmb < drmem_info->lmbs);
>> + BUG_ON(lmb >= drmem_info->lmbs + drmem_info->n_lmbs);
>
> BUG_ON() shall be avoided unless absolutely necessary.
> Wouldn't WARN_ON() together with an early return be enough ?
Not sure what a sensible early return behavior would be. If the iterator
doesn't advance the pointer the behavior will be a hang.
BUG_ON a bounds-check failure is appropriate here; many users of this
API will corrupt memory otherwise.
>> +
>> + if ((lmb - drmem_info->lmbs) % resched_interval == 0)
>> + cond_resched();
>
> Do you need something that precise ? Can't you use 16 or 32 and use a
> logical AND instead of a MODULO ?
Eh if you're executing in this code you've already lost with respect to
performance considerations at this level, see the discussion on v1. I'll
use 16 since I'm going to reroll the patch though.
> And what garanties that lmb is always an element of a table based at
> drmem_info->lmbs ?
Well, that's its only intended use right now. There should not be any
other arrays of drmem_lmb objects, and I hope we don't gain any.
> What about:
>
> static inline struct drmem_lmb *drmem_lmb_next(struct drmem_lmb *lmb,
> struct drmem_lmb *start)
> {
> const unsigned int resched_interval = 16;
>
> if ((++lmb - start) & resched_interval == 0)
^^^
Did you mean '%' here? The bitwise AND doesn't do what I want.
Otherwise, making drmem_lmb_next() more general by adding a 'start'
argument could ease refactoring to come, so I'll do that.
next prev parent reply other threads:[~2020-08-12 13:48 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-12 1:20 [PATCH v2] powerpc/pseries: explicitly reschedule during drmem_lmb list traversal Nathan Lynch
2020-08-12 5:19 ` Christophe Leroy
2020-08-12 13:46 ` Nathan Lynch [this message]
2020-08-12 14:26 ` Christophe Leroy
2020-08-12 16:22 ` Tyrel Datwyler
2020-08-13 0:28 ` Michael Ellerman
2020-08-13 1:07 ` Nathan Lynch
2020-08-17 3:45 ` Michael Ellerman
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=878sekyo2l.fsf@linux.ibm.com \
--to=nathanl@linux.ibm.com \
--cc=cheloha@linux.ibm.com \
--cc=christophe.leroy@csgroup.eu \
--cc=ldufour@linux.ibm.com \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=tyreld@linux.ibm.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 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.