From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 88F9EC433F5 for ; Sat, 8 Oct 2022 17:06:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229502AbiJHRGK (ORCPT ); Sat, 8 Oct 2022 13:06:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44572 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229481AbiJHRGH (ORCPT ); Sat, 8 Oct 2022 13:06:07 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 41F3D2CDC4; Sat, 8 Oct 2022 10:06:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1665248745; bh=Tb8EH9348vkLCbF5WRu35I60NkPtSNYF6aeCGlhW9kQ=; h=X-UI-Sender-Class:Subject:From:To:Cc:References:Date:In-Reply-To; b=bQtTi2VbW1YYgScaaxy7v8jiINBt8DOIpV9nyPXLUpvDRe7FN23iArjDFb9zaAhKE F+SblUS92zFQSaW/gETz94/mCfyWXN0sZrAQSctmT/9dYtNPzqQqbUO0wqMAMa2Vys fk/C6TaNEt5uafjGzsFH5hoFY/DmBE+sgbMFCxNE= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [192.168.2.100] ([84.162.5.241]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MWASY-1ofbkZ0fms-00Xd9r; Sat, 08 Oct 2022 19:05:45 +0200 Subject: Re: [PATCH v7 07/10] tmp, tmp_tis: Implement usage counter for locality From: Lino Sanfilippo To: Jarkko Sakkinen Cc: peterhuewe@gmx.de, jgg@ziepe.ca, stefanb@linux.vnet.ibm.com, linux@mniewoehner.de, linux-integrity@vger.kernel.org, linux-kernel@vger.kernel.org, l.sanfilippo@kunbus.com, lukas@wunner.de, p.rosenberger@kunbus.com References: <20220629232653.1306735-1-LinoSanfilippo@gmx.de> <20220629232653.1306735-8-LinoSanfilippo@gmx.de> <744ad6e1-c4ad-1e6d-f94d-98aa5b105dc6@gmx.de> Message-ID: <09eefdab-f677-864a-99f7-869d7a8744c2@gmx.de> Date: Sat, 8 Oct 2022 19:05:44 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:E9hCD+ASl+nhJQlUzQvP/M49+j8ZzuAlF5b6qQu10gY0f/KCTZi iaVUxLeM8T9pOSmawjLX7tdLxD3PgWzI3hQTTahhsEaKzyac+KrznZf5txfz4tol+C6A8vX bDTK+610WvPKeayKA0+exD5eslqF7jpC3CcIx4pZPcUy7bnOMVfgekV4Kclj9AmH/oy/kSJ z/42c/B/31Ub5lx1bI1IA== X-UI-Out-Filterresults: notjunk:1;V03:K0:NvAC+Gzd4g4=:KkAC2SGtT4Kx9pDqFYEXGD UUszEekz7Xp5/UXRpuesqmhn2D+pRIzkrYmjd/0B1DY9fUrdpffiXJKtHJqVsTvKJJuyDJpMU zyTUEED/4VJTViWIMN2ZsYBNiCGHEb2cq+fmig9DsmblDBV+e1N/3rNusNaOTvJUS626K3vSa ipH8oGhsMJE2MU1HuX+NCGHfeKUJq7eKnqp+9MR9BpxXJbaZ1XjsQ3zM/dpz5oMouNmG78cwD fNgwo+yUbsUuiPZ3Kvj7lcSp7suOooWILNoKjLD2D8G98g8xeo1ETBraqOP7jq+6NwTOlCOzH JfnX9Udm1aDkrpEpkBX1wK4mRwJjQ7o1kzKsrV7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zreZOe0LCT/35SRdEFbCG7TgYpfetfckfxzC6lcsZiHN2GenQ7HBoSg/2hxXboVmnOE QAD5rbYhNWW/XNJtTHS3cab6Rk4Xg+dvR21Xat91n0j9Eq5rnlHIzkwmqU5yowB6ofH80YPxj 1IIMxHXMqcJ+GcI7jJRAhR4wc0v7x/Q0NdeZfwM1svyAh Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Jarkko, On 28.07.22 at 17:45, Lino Sanfilippo wrote: >>> >>> This means switching to a complete new locking scheme which affects ma= ny >>> parts of the TIS core code. It is also not directly related to what th= is patch series >>> is about, namely activating the interrupts for TPM TIS. >>> >>> I suggest to first finish polishing this series especially since there= have >>> only been minor issues in the last versions. Once the interrupts work = we >>> still can think of implementing another lock handling in a follow up s= eries. >> >> So what if you would use kref instead here? >> > > Sure, that should not be too difficult to do. I will implement this for = the next version. > > Regards, > Lino > First of all, sorry for this very late reply. Unfortunately in the last we= eks I was not able to work further on this series due to my private situation. Nevertheless I tried to implement your suggestion (using krefs for the loc= ality counting) meanwhile. However krefs turned out to be a rather bad fit for this task. The reason is that for the locality handling we have to perform a certain = action (i.e. writing to the access register) on two occasions: 1. When the locality is requested while no locality is active 2. When the locality has been released the number of times it has been req= uested before Since a kref is designed to track the lifetime of an object which is freed= as soon as the kref counter hits 0, it starts with a counter of 1 when it is created, not= with a counter 0 (as we would need it, since at the beginning nothing has claimed the local= ity yet). Furthermore while kref provides a built-in mechanism to execute a function= when the counter hits 0 it does not provide anything similar for the case that the counter = is increased the first time (i.e when we want to claim the locality by writing to the acces= s register). So although certainly doable I do not see much gain from using krefs in th= is case. Again, sorry for this late reply. Regards, Lino