From: Dave Hansen <haveblue@us.ibm.com>
To: Chandra Seetharaman <sekharan@us.ibm.com>
Cc: ckrm-tech@lists.sourceforge.net, linux-mm@kvack.org
Subject: Re: [PATCH 3/6] CKRM: Add limit support for mem controller
Date: Mon, 04 Apr 2005 07:10:50 -0700 [thread overview]
Message-ID: <1112623850.24676.8.camel@localhost> (raw)
In-Reply-To: <20050402031346.GD23284@chandralinux.beaverton.ibm.com>
On Fri, 2005-04-01 at 19:13 -0800, Chandra Seetharaman wrote:
> +static void
> +set_impl_guar_children(struct ckrm_mem_res *parres)
> +{
> + struct ckrm_core_class *child = NULL;
> + struct ckrm_mem_res *cres;
> + int nr_dontcare = 1; /* for defaultclass */
> + int guar, impl_guar;
> + int resid = mem_rcbs.resid;
This sets off one of my internal "this is just wrong" checks: too many
variables for a function that short. Can that function be broken up a
bit?
Also, I get a little nervous when I see variable names like "parres" and
"mem_rcbs". Can they get some real names? If they're going to be
nonsense, at least make it understandable, like
>+ cres = ckrm_get_res_class(child, resid, struct ckrm_mem_res);
I think there are probably enough calls to ckrm_get_res_class() with
just the memory controller struct to justify wrapping it in its own
macro. sysfs does lots of tricks like this, and that's the approach
that it takes to hide some of the ugliness.
> + while ((child = ckrm_get_next_child(parres->core, child)) != NULL) {
You might even want a for_each_child() macro or something. That looks a
little hairy.
>
> + /* treat NULL cres as don't care as that child is just
> being
> + * created.
> + * FIXME: need a better way to handle this case.
> + */
> + if (!cres || cres->pg_guar == CKRM_SHARE_DONTCARE)
> + nr_dontcare++;
If it needs to be fixed, why did you post it?
> + parres->nr_dontcare = nr_dontcare;
> + guar = (parres->pg_guar == CKRM_SHARE_DONTCARE) ?
> + parres->impl_guar : parres->pg_unused;
> + impl_guar = guar / parres->nr_dontcare;
Please don't tell me this is too messy:
parres->nr_dontcare = nr_dontcare;
if (parres->pg_guar == CKRM_SHARE_DONTCARE)
guar = parres->impl_guar;
else
guar = parres->pg_unused;
impl_guar = guar / parres->nr_dontcare;
All of this 'impl' stufff just looks weird. I might even wrap that
CKRM_SHARE_DONTCARE logic in a little function. get_child_guarantee()?
All of the logic surrounding that pg_{limit,guar} being set to DONTCARE
seems like it was special-cased in after it was originally written.
Like someone went back over it, adding conditionals everywhere. It
greatly adds to the clutter.
"DONTCARE" is also multiplexed. It means "no guarantee" or "no limit"
depending on context. I don't think it would hurt to have one variable
for each of these cases.
What does "impl" stand for, anyway? implied? implicit? implemented?
-- Dave
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"aart@kvack.org"> aart@kvack.org </a>
next prev parent reply other threads:[~2005-04-04 14:10 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-04-02 3:13 Chandra Seetharaman
2005-04-04 14:10 ` Dave Hansen [this message]
2005-04-05 17:42 ` Chandra Seetharaman
2005-04-05 17:59 ` Dave Hansen
2005-04-05 18:26 ` Chandra Seetharaman
2005-04-05 19:01 ` [ckrm-tech] " Dave Hansen
2005-04-05 19:48 ` Chandra Seetharaman
[not found] ` <1112732985.4200.1973.camel@stark>
2005-04-06 16:48 ` Chandra Seetharaman
2005-04-06 18:35 ` Gerrit Huizenga
2005-05-19 0:32 Chandra Seetharaman
2005-06-24 22:24 Chandra Seetharaman
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=1112623850.24676.8.camel@localhost \
--to=haveblue@us.ibm.com \
--cc=ckrm-tech@lists.sourceforge.net \
--cc=linux-mm@kvack.org \
--cc=sekharan@us.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox