From: Andrew Morton <akpm@linux-foundation.org>
To: steiner@sgi.com
Cc: linux-kernel@vger.kernel.org
Subject: Re: [Patch 02/12] GRU - add user request to explicitly unload a gru context
Date: Mon, 8 Jun 2009 16:05:25 -0700 [thread overview]
Message-ID: <20090608160525.86f38739.akpm@linux-foundation.org> (raw)
In-Reply-To: <20090608171946.000713000@sgi.com>
On Mon, 08 Jun 2009 12:16:50 -0500
steiner@sgi.com wrote:
> /*
> + * Free all kernel contexts that are not currently in use.
> + * Returns 0 if all freed, else number of inuse context.
> + */
> +static int gru_free_kernel_contexts(void)
> +{
> + struct gru_blade_state *bs;
> + struct gru_thread_state *kgts;
> + int bid, ret = 0;
> +
> + for (bid = 0; bid < GRU_MAX_BLADES; bid++) {
> + bs = gru_base[bid];
> + if (!bs)
> + continue;
> + if (down_write_trylock(&bs->bs_kgts_sema)) {
trylocks are always lame - they add a rarely-executed code path where
bugs can lurk. They're often an admission that the locking is screwed
up.
I don't know if the latter is true here, but it would be helpful to add
a comment explaining what's going on, and why this unusual and
troublesome locking primitive is being used.
> + kgts = bs->bs_kgts;
> + if (kgts && kgts->ts_gru)
> + gru_unload_context(kgts, 0);
> + kfree(kgts);
> + bs->bs_kgts = NULL;
> + up_write(&bs->bs_kgts_sema);
nit: the kfree() can be moved outside the locked region.
> + } else {
> + ret++;
> + }
> + }
> + return ret;
> +}
next prev parent reply other threads:[~2009-06-08 23:05 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-08 17:16 [Patch 00/12] GRU - GRU Driver Updates steiner
2009-06-08 17:16 ` [Patch 01/12] GRU - fix cache coherency issues with instruction retry steiner
2009-06-08 17:16 ` [Patch 02/12] GRU - add user request to explicitly unload a gru context steiner
2009-06-08 23:05 ` Andrew Morton [this message]
2009-06-12 17:51 ` Jack Steiner
2009-06-08 17:16 ` [Patch 03/12] GRU - fix automatic retry of gru instruction failures steiner
2009-06-08 17:16 ` [Patch 04/12] GRU - collect per-context user statistics steiner
2009-06-08 23:07 ` Andrew Morton
2009-06-10 3:08 ` Jack Steiner
2009-06-08 17:16 ` [Patch 05/12] GRU - delete user request for fetching chiplet status steiner
2009-06-08 17:16 ` [Patch 06/12] GRU - cleanup gru inline functions steiner
2009-06-08 17:16 ` [Patch 07/12] GRU - generic infrastructure for context options steiner
2009-06-08 17:16 ` [Patch 08/12] GRU - add user request to specify gru slice steiner
2009-06-08 17:16 ` [Patch 09/12] GRU - fix potential use-after-free when purging GRU tlbs steiner
2009-06-08 17:16 ` [Patch 10/12] GRU - fixes to grudump utility steiner
2009-06-08 17:16 ` [Patch 11/12] GRU - remove references to the obsolete global status handle steiner
2009-06-08 17:17 ` [Patch 12/12] GRU - copyright fixes steiner
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=20090608160525.86f38739.akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=steiner@sgi.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
all inboxes | Powered by JetHome®