From: Jarkko Sakkinen <jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
To: James Bottomley
<James.Bottomley-d9PhHud1JfjCXq6kfMZ53/egYHeGw8Jk@public.gmane.org>
Cc: linux-security-module-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
tpmdd-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org,
open list <linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: Re: [PATCH 2/2] tpm2-space: add handling for global session exhaustion
Date: Fri, 27 Jan 2017 08:51:11 +0200 [thread overview]
Message-ID: <20170127065111.ytlbb5gsh3khnpay@intel.com> (raw)
In-Reply-To: <1485477952.2457.55.camel-d9PhHud1JfjCXq6kfMZ53/egYHeGw8Jk@public.gmane.org>
On Thu, Jan 26, 2017 at 04:45:52PM -0800, James Bottomley wrote:
> On Thu, 2017-01-26 at 14:56 +0200, Jarkko Sakkinen wrote:
> > On Mon, Jan 23, 2017 at 09:38:33PM -0800, James Bottomley wrote:
> > > In a TPM2, sessions can be globally exhausted once there are
> > > TPM_PT_ACTIVE_SESSION_MAX of them (even if they're all context
> > > saved). The Strategy for handling this is to keep a global count of
> > > all the sessions along with their creation time. Then if we see
> > > the TPM run out of sessions (via the TPM_RC_SESSION_HANDLES) we
> > > first wait for one to become free, but if it doesn't, we forcibly
> > > evict an existing one. The eviction strategy waits until the
> > > current command is repeated to evict the session which should
> > > guarantee there is an available slot.
> > >
> > > On the force eviction case, we make sure that the victim session is
> > > at least SESSION_TIMEOUT old (currently 2 seconds). The wait queue
> > > for session slots is a FIFO one, ensuring that once we run out of
> > > sessions, everyone will get a session in a bounded time and once
> > > they get one, they'll have SESSION_TIMEOUT to use it before it may
> > > be subject to eviction.
> > >
> > > Signed-off-by: James Bottomley <
> > > James.Bottomley-d9PhHud1JfjCXq6kfMZ53/egYHeGw8Jk@public.gmane.org>
> >
> > This is not a proper review yet. Just quick question: why do you need
> > a real time (i.e. created)? Maybe in the force eviction case it would
> > be enough to sleep lets say 500 ms and pick the victim with smallest
> > number? I.e. just have increasing u64 counter instead of real time.
>
> So that if the oldest session has already been around for > 2s there's
> no need to wait. In order to guarantee everyone gets a session for at
> least 2s without tracking the age of sessions, you'd have to sleep for
> 2s after you find the oldest session.
>
> > That would simplify this patch a lot and does not prevent to refine
> > later on if workloads show need for more complex logic.
>
> An increasing monotonic counter would actually not be much simpler: all
> you could really cut out would be the four lines and two comments at
> the bottom of the for loop in tpm2_session_wait() which check the age
> of the found session.
>
> James
Right. Thanks for explaining this. I'll check the code with more detail
ASAP.
/Jarkko
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
WARNING: multiple messages have this Message-ID (diff)
From: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
To: James Bottomley <James.Bottomley@HansenPartnership.com>
Cc: tpmdd-devel@lists.sourceforge.net,
open list <linux-kernel@vger.kernel.org>,
linux-security-module@vger.kernel.org
Subject: Re: [PATCH 2/2] tpm2-space: add handling for global session exhaustion
Date: Fri, 27 Jan 2017 08:51:11 +0200 [thread overview]
Message-ID: <20170127065111.ytlbb5gsh3khnpay@intel.com> (raw)
In-Reply-To: <1485477952.2457.55.camel@HansenPartnership.com>
On Thu, Jan 26, 2017 at 04:45:52PM -0800, James Bottomley wrote:
> On Thu, 2017-01-26 at 14:56 +0200, Jarkko Sakkinen wrote:
> > On Mon, Jan 23, 2017 at 09:38:33PM -0800, James Bottomley wrote:
> > > In a TPM2, sessions can be globally exhausted once there are
> > > TPM_PT_ACTIVE_SESSION_MAX of them (even if they're all context
> > > saved). The Strategy for handling this is to keep a global count of
> > > all the sessions along with their creation time. Then if we see
> > > the TPM run out of sessions (via the TPM_RC_SESSION_HANDLES) we
> > > first wait for one to become free, but if it doesn't, we forcibly
> > > evict an existing one. The eviction strategy waits until the
> > > current command is repeated to evict the session which should
> > > guarantee there is an available slot.
> > >
> > > On the force eviction case, we make sure that the victim session is
> > > at least SESSION_TIMEOUT old (currently 2 seconds). The wait queue
> > > for session slots is a FIFO one, ensuring that once we run out of
> > > sessions, everyone will get a session in a bounded time and once
> > > they get one, they'll have SESSION_TIMEOUT to use it before it may
> > > be subject to eviction.
> > >
> > > Signed-off-by: James Bottomley <
> > > James.Bottomley@HansenPartnership.com>
> >
> > This is not a proper review yet. Just quick question: why do you need
> > a real time (i.e. created)? Maybe in the force eviction case it would
> > be enough to sleep lets say 500 ms and pick the victim with smallest
> > number? I.e. just have increasing u64 counter instead of real time.
>
> So that if the oldest session has already been around for > 2s there's
> no need to wait. In order to guarantee everyone gets a session for at
> least 2s without tracking the age of sessions, you'd have to sleep for
> 2s after you find the oldest session.
>
> > That would simplify this patch a lot and does not prevent to refine
> > later on if workloads show need for more complex logic.
>
> An increasing monotonic counter would actually not be much simpler: all
> you could really cut out would be the four lines and two comments at
> the bottom of the for loop in tpm2_session_wait() which check the age
> of the found session.
>
> James
Right. Thanks for explaining this. I'll check the code with more detail
ASAP.
/Jarkko
next prev parent reply other threads:[~2017-01-27 6:51 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-24 5:35 [PATCH 0/2] Add session handling to tpm spaces James Bottomley
[not found] ` <1485236113.2534.69.camel-d9PhHud1JfjCXq6kfMZ53/egYHeGw8Jk@public.gmane.org>
2017-01-24 5:37 ` [PATCH 1/2] tpm2: add session handle context saving and restoring to the space code James Bottomley
2017-01-24 5:37 ` James Bottomley
2017-01-26 12:51 ` Jarkko Sakkinen
[not found] ` <20170126125151.32sky3tajp6zigpd-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2017-01-26 15:18 ` James Bottomley
2017-01-26 15:18 ` James Bottomley
[not found] ` <1485443929.2457.5.camel-d9PhHud1JfjCXq6kfMZ53/egYHeGw8Jk@public.gmane.org>
2017-01-27 6:45 ` Jarkko Sakkinen
2017-01-27 6:45 ` Jarkko Sakkinen
2017-01-27 22:06 ` Ken Goldman
2017-01-26 16:26 ` James Bottomley
2017-01-26 16:26 ` James Bottomley
[not found] ` <1485447979.2457.23.camel-d9PhHud1JfjCXq6kfMZ53/egYHeGw8Jk@public.gmane.org>
2017-01-27 6:49 ` Jarkko Sakkinen
2017-01-27 6:49 ` Jarkko Sakkinen
2017-01-24 5:38 ` [PATCH 2/2] tpm2-space: add handling for global session exhaustion James Bottomley
[not found] ` <1485236313.2534.73.camel-d9PhHud1JfjCXq6kfMZ53/egYHeGw8Jk@public.gmane.org>
2017-01-26 12:56 ` Jarkko Sakkinen
2017-01-26 12:56 ` Jarkko Sakkinen
[not found] ` <20170126125615.dt5hnfbpmtxk7xlq-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2017-01-27 0:45 ` James Bottomley
2017-01-27 0:45 ` James Bottomley
[not found] ` <1485477952.2457.55.camel-d9PhHud1JfjCXq6kfMZ53/egYHeGw8Jk@public.gmane.org>
2017-01-27 6:51 ` Jarkko Sakkinen [this message]
2017-01-27 6:51 ` Jarkko Sakkinen
-- strict thread matches above, loose matches on Subject: below --
2017-01-28 0:31 [PATCH 0/2] Add session handling to tpm spaces James Bottomley
2017-01-28 0:33 ` [PATCH 2/2] tpm2-space: add handling for global session exhaustion James Bottomley
[not found] ` <1485563634.3229.43.camel-d9PhHud1JfjCXq6kfMZ53/egYHeGw8Jk@public.gmane.org>
2017-01-29 22:02 ` Jarkko Sakkinen
[not found] ` <20170129220219.oqv7fuofvcqy3gzh-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2017-01-31 23:24 ` James Bottomley
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=20170127065111.ytlbb5gsh3khnpay@intel.com \
--to=jarkko.sakkinen-vuqaysv1563yd54fqh9/ca@public.gmane.org \
--cc=James.Bottomley-d9PhHud1JfjCXq6kfMZ53/egYHeGw8Jk@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-security-module-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=tpmdd-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.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 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.