mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Moger, Babu" <babu.moger@amd.com>
To: Reinette Chatre <reinette.chatre@intel.com>,
	corbet@lwn.net, tglx@linutronix.de, mingo@redhat.com,
	bp@alien8.de
Cc: fenghua.yu@intel.com, dave.hansen@linux.intel.com,
	x86@kernel.org, hpa@zytor.com, paulmck@kernel.org,
	akpm@linux-foundation.org, quic_neeraju@quicinc.com,
	rdunlap@infradead.org, damien.lemoal@opensource.wdc.com,
	songmuchun@bytedance.com, peterz@infradead.org,
	jpoimboe@kernel.org, pbonzini@redhat.com,
	chang.seok.bae@intel.com, pawan.kumar.gupta@linux.intel.com,
	jmattson@google.com, daniel.sneddon@linux.intel.com,
	sandipan.das@amd.com, tony.luck@intel.com, james.morse@arm.com,
	linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
	bagasdotme@gmail.com, eranian@google.com,
	christophe.leroy@csgroup.eu, jarkko@kernel.org,
	adrian.hunter@intel.com, quic_jiles@quicinc.com,
	peternewman@google.com
Subject: Re: [PATCH v6 5/8] x86/resctrl: Unwind the errors inside rdt_enable_ctx
Date: Mon, 7 Aug 2023 11:19:20 -0500	[thread overview]
Message-ID: <ef509f34-954d-61c0-f730-2cbc93eae4b8@amd.com> (raw)
In-Reply-To: <9fd70ef3-ca90-65e3-4746-7d574bdd159b@intel.com>

Hi Reinette,

On 8/4/23 15:41, Reinette Chatre wrote:
> Hi Babu,
> 
> On 7/19/2023 4:22 PM, Babu Moger wrote:
>> rdt_enable_ctx() takes care of enabling the features provided during
> 
> "rdt_enable_ctx() takes care of enabling" can just be "rdt_enable_ctx()
> enables"

Sure.

> 
>> resctrl mount. The error unwinding of rdt_enable_ctx is done from the
>> caller rdt_get_tree. This is not ideal and can cause some error unwinding
>> to be omitted.
>>
> 
> Please consistently use () to indicate function names (in
> changelog and subject).

Sure.

> 
> "This is not ideal and can cause some error unwinding to be omitted."
> is a bit vague. How about (in a new paragraph):
> "Additions to rdt_enable_ctx() are required to also modify error paths
> of rdt_enable_ctx() callers to ensure correct unwinding if errors
> are encountered after calling rdt_enable_ctx(). This is error prone."

Sure.

> 
>> Fix this by moving all the error unwinding inside rdt_enable_ctx.
> 
> "Fix" creates expectation for a "fixes" tag which is not needed here. This
> refactors code to simplify future additions.

Sure.
> 
> Even so, I do not think this solution addresses the stated problem (more
> below).
> 
>>
>> Suggested-by: Reinette Chatre <reinette.chatre@intel.com>
>> Signed-off-by: Babu Moger <babu.moger@amd.com>
>> ---
>>  arch/x86/kernel/cpu/resctrl/rdtgroup.c |   31 +++++++++++++++++++++++--------
>>  1 file changed, 23 insertions(+), 8 deletions(-)
>>
>> diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
>> index 3010e3a1394d..9a7204f71d2d 100644
>> --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c
>> +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
>> @@ -2381,15 +2381,31 @@ static int rdt_enable_ctx(struct rdt_fs_context *ctx)
>>  {
>>  	int ret = 0;
>>  
>> -	if (ctx->enable_cdpl2)
>> +	if (ctx->enable_cdpl2) {
>>  		ret = resctrl_arch_set_cdp_enabled(RDT_RESOURCE_L2, true);
>> +		if (ret)
>> +			goto out;
>> +	}
>>  
>> -	if (!ret && ctx->enable_cdpl3)
>> +	if (ctx->enable_cdpl3) {
>>  		ret = resctrl_arch_set_cdp_enabled(RDT_RESOURCE_L3, true);
>> +		if (ret)
>> +			goto out_cdpl2;
>> +	}
>>  
>> -	if (!ret && ctx->enable_mba_mbps)
>> +	if (ctx->enable_mba_mbps) {
>>  		ret = set_mba_sc(true);
>> +		if (ret)
>> +			goto out_cdpl3;
>> +	}
>>  
>> +	return 0;
>> +
>> +out_cdpl3:
>> +	resctrl_arch_set_cdp_enabled(RDT_RESOURCE_L3, false);
>> +out_cdpl2:
>> +	resctrl_arch_set_cdp_enabled(RDT_RESOURCE_L2, false);
> 
> Be careful here. There is no dependency between L3 and L2 CDP ...
> if L3 CDP was enabled it does not mean that L2 CDP was enabled also.
> Similarly, if the software controller was enabled it does not mean that
> CDP was also enabled.
> Since resctrl_arch_set_cdp_enabled() does much more than just change
> a flag value I think these should first check if it was enabled
> before disabling the feature.

Yes. Agree.
> 
>> +out:
>>  	return ret;
>>  }
>>  
>> @@ -2497,13 +2513,13 @@ static int rdt_get_tree(struct fs_context *fc)
>>  	}
>>  
>>  	ret = rdt_enable_ctx(ctx);
>> -	if (ret < 0)
>> -		goto out_cdp;
>> +	if (ret)
>> +		goto out;
>>  
>>  	ret = schemata_list_create();
>>  	if (ret) {
>>  		schemata_list_destroy();
>> -		goto out_mba;
>> +		goto out_ctx;
>>  	}
>>  
>>  	closid_init();
>> @@ -2562,10 +2578,9 @@ static int rdt_get_tree(struct fs_context *fc)
>>  	kernfs_remove(kn_info);
>>  out_schemata_free:
>>  	schemata_list_destroy();
>> -out_mba:
>> +out_ctx:
>>  	if (ctx->enable_mba_mbps)
>>  		set_mba_sc(false);
>> -out_cdp:
>>  	cdp_disable_all();
>>  out:
>>  	rdt_last_cmd_clear();
>>
> 
> The problem statement in the changelog was that rdt_get_tree() is
> doing error unwinding of rdt_enable_ctx(). Looking at the above it
> seems that the problem remains ... callers of rdt_enable_ctx()
> still need to know all internals of that function to do error
> unwind correctly. Could it perhaps be made simpler with a new
> rdt_disable_ctx() that undoes rdt_enable_ctx()? New additions
> to rdt_enable_ctx() would have more clarity where changes are
> needed and callers only need to call a single rdt_disable_ctx().
> 

Yes. We can do that.
-- 
Thanks
Babu Moger

  reply	other threads:[~2023-08-07 16:19 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-19 23:21 [PATCH v6 0/8] x86/resctrl: Miscellaneous resctrl features Babu Moger
2023-07-19 23:21 ` [PATCH v6 1/8] x86/resctrl: Add multiple tasks to the resctrl group at once Babu Moger
2023-07-19 23:21 ` [PATCH v6 2/8] x86/resctrl: Simplify rftype flag definitions Babu Moger
2023-07-19 23:21 ` [PATCH v6 3/8] x86/resctrl: Rename rftype flags for consistency Babu Moger
2023-07-19 23:21 ` [PATCH v6 4/8] x86/resctrl: Add comments on RFTYPE flags hierarchy Babu Moger
2023-08-04 20:39   ` Reinette Chatre
2023-08-07 15:40     ` Moger, Babu
2023-08-11 20:15     ` Moger, Babu
2023-07-19 23:22 ` [PATCH v6 5/8] x86/resctrl: Unwind the errors inside rdt_enable_ctx Babu Moger
2023-08-04 20:41   ` Reinette Chatre
2023-08-07 16:19     ` Moger, Babu [this message]
2023-07-19 23:22 ` [PATCH v6 6/8] x86/resctrl: Move default control group creation during mount Babu Moger
2023-08-04 20:42   ` Reinette Chatre
2023-08-08 16:22     ` Moger, Babu
2023-07-19 23:22 ` [PATCH v6 7/8] x86/resctrl: Introduce "-o debug" mount option Babu Moger
2023-08-04 20:42   ` Reinette Chatre
2023-08-08 16:29     ` Moger, Babu
2023-08-08 17:09       ` Reinette Chatre
2023-07-19 23:22 ` [PATCH v6 8/8] x86/resctrl: Display hardware ids of resource groups Babu Moger
2023-08-02  1:36 ` [PATCH v6 0/8] x86/resctrl: Miscellaneous resctrl features Shaopeng Tan (Fujitsu)
2023-08-08 16:48   ` Moger, Babu

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=ef509f34-954d-61c0-f730-2cbc93eae4b8@amd.com \
    --to=babu.moger@amd.com \
    --cc=adrian.hunter@intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=bagasdotme@gmail.com \
    --cc=bp@alien8.de \
    --cc=chang.seok.bae@intel.com \
    --cc=christophe.leroy@csgroup.eu \
    --cc=corbet@lwn.net \
    --cc=damien.lemoal@opensource.wdc.com \
    --cc=daniel.sneddon@linux.intel.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=eranian@google.com \
    --cc=fenghua.yu@intel.com \
    --cc=hpa@zytor.com \
    --cc=james.morse@arm.com \
    --cc=jarkko@kernel.org \
    --cc=jmattson@google.com \
    --cc=jpoimboe@kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=paulmck@kernel.org \
    --cc=pawan.kumar.gupta@linux.intel.com \
    --cc=pbonzini@redhat.com \
    --cc=peternewman@google.com \
    --cc=peterz@infradead.org \
    --cc=quic_jiles@quicinc.com \
    --cc=quic_neeraju@quicinc.com \
    --cc=rdunlap@infradead.org \
    --cc=reinette.chatre@intel.com \
    --cc=sandipan.das@amd.com \
    --cc=songmuchun@bytedance.com \
    --cc=tglx@linutronix.de \
    --cc=tony.luck@intel.com \
    --cc=x86@kernel.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 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®