Linux Integrity Measurement development
 help / color / mirror / Atom feed
From: Jarkko Sakkinen <jarkko@kernel.org>
To: Surendran Kanagaraj <surenkj@amazon.com>
Cc: corbet@lwn.net, graf@amazon.de, gunnarku@amazon.com,
	jgg@ziepe.ca, joshlev@amazon.com, leitao@debian.org,
	linux-doc@vger.kernel.org, linux-integrity@vger.kernel.org,
	linux-kernel@vger.kernel.org, nh-open-source@amazon.com,
	noodles@earth.li, peterhuewe@gmx.de, rdunlap@infradead.org,
	skhan@linuxfoundation.org
Subject: Re: [RFC PATCH v4 1/8] tpm: Add a single table for all TPM wait limits
Date: Tue, 1 Dec 2026 18:42:51 +0200	[thread overview]
Message-ID: <aw75C49kCbcqAEZe@kernel.org> (raw)
In-Reply-To: <aw7AZ86jtK8HFYcl@kernel.org>

On Tue, Dec 01, 2026 at 02:41:15PM +0200, Jarkko Sakkinen wrote:
> On Tue, Dec 01, 2026 at 08:14:08AM +0000, Surendran Kanagaraj wrote:
> > On Sat, Nov 28, 2026 at 01:30:15AM +0200, Jarkko Sakkinen wrote:
> > > On Fri, Nov 27, 2026 at 10:23:47PM +0000, Surendran Kanagaraj wrote:
> > > > Yes, that should work. Something like this:
> > > >
> > > > 	struct tpm_cmd_duration {
> > > > 		/* TPM 2.0: command code or TPM 1.x: duration class */
> > > > 		u32 cmd;
> > > > 		u32 duration;	/* msecs */
> > > > 	};
> > > >
> > > > 	/* in struct tpm_chip, in place of chip->duration[] */
> > > > 	struct tpm_cmd_duration durations[TPM_MAX_DURATIONS];
> > > >
> > > > eg:
> > > > 	/* TPM 1.x */
> > > > 	chip->durations[0] = { TPM_SHORT, 750 }
> > > >
> > > > 	/* TPM 2.0 */
> > > > 	chip->durations[2] = { TPM2_CC_GET_RANDOM, 2000 }
> > >
> > > Hmm... in theory TPM 1.x commands could be "normalized" to have same
> > > format. Is that because of sysfs files?
> > 
> > Yes partly. It's doable. I agree it would unify the format nicely. My
> > hesitation is that the per chip copy grows from 3 values to 123
> > entries just to match the format. Also the code paths which work with
> > duration class - sysfs (stable ABI), vendor overrides etc would need
> > additional logic. Would you prefer the normalized version?
> 
> Memory consumption is not a concern here.

And as a general rule it is better to optimize a clean data flow
over performance at first almost for any feature. Too slow but
clean version is superior over fast but wrong.

Why in some cases we end up to using unions or data packing is often due
to evolution, legacy and architectural constraints; or parametrical
growth in memory consumption.

I.e. when space needs to be carved out in already constrained space
and/or memory consumption is more than O(1) unions *might* start to make
sense. Usually this should happen only when conditions enforce to make
that choice rather than as "creative innovation".

Linux is a high-grade software project but that position is retained by
not being too clever; rather than being clever (I wrote this despite
Claude phrasing :-) ). "Not being too clever" code is what makes
e.g., data centers work.

Br, Jarkko

  parent reply	other threads:[~2026-12-01 16:42 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-18  7:38 [RFC PATCH v4 0/8] tpm: Rework timeout and duration handling Surendran Kanagaraj
2026-11-18  7:38 ` [RFC PATCH v4 1/8] tpm: Add a single table for all TPM wait limits Surendran Kanagaraj
2026-11-20 12:19   ` Jarkko Sakkinen
2026-11-25 23:00   ` Surendran Kanagaraj
2026-11-26 19:02     ` Jarkko Sakkinen
2026-11-27 22:23       ` Surendran Kanagaraj
2026-11-27 23:30         ` Jarkko Sakkinen
2026-12-01  8:14           ` Surendran Kanagaraj
2026-12-01 12:41             ` Jarkko Sakkinen
2026-12-01 15:36               ` Surendran Kanagaraj
2026-12-01 16:42               ` Jarkko Sakkinen [this message]
2026-11-18  7:38 ` [RFC PATCH v4 2/8] tpm: Wire the timing setup to the limits table Surendran Kanagaraj
2026-11-18  7:38 ` [RFC PATCH v4 3/8] tpm: Take command durations from " Surendran Kanagaraj
2026-11-18  7:38 ` [RFC PATCH v4 4/8] tpm: Bound core and CRB waits by " Surendran Kanagaraj
2026-11-20 12:22   ` Jarkko Sakkinen
2026-11-24 20:49     ` Surendran Kanagaraj
2026-11-18  7:49 ` [RFC PATCH v4 5/8] tpm: Drop the jiffies timing fields from struct tpm_chip Surendran Kanagaraj
2026-11-18  7:49 ` [RFC PATCH v4 6/8] tpm: Add the tpm.limits= parameter Surendran Kanagaraj
2026-11-18  7:49 ` [RFC PATCH v4 7/8] tpm: Show timeouts and durations for TPM 2.0 chips Surendran Kanagaraj
2026-11-18  7:49 ` [RFC PATCH v4 8/8] tpm_crb: Raise the limits for Amazon NitroTPM Surendran Kanagaraj

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=aw75C49kCbcqAEZe@kernel.org \
    --to=jarkko@kernel.org \
    --cc=corbet@lwn.net \
    --cc=graf@amazon.de \
    --cc=gunnarku@amazon.com \
    --cc=jgg@ziepe.ca \
    --cc=joshlev@amazon.com \
    --cc=leitao@debian.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-integrity@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nh-open-source@amazon.com \
    --cc=noodles@earth.li \
    --cc=peterhuewe@gmx.de \
    --cc=rdunlap@infradead.org \
    --cc=skhan@linuxfoundation.org \
    --cc=surenkj@amazon.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