Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp6540077ybh; Thu, 8 Aug 2019 01:45:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqyP8D0oUFN2/fpTjtZaQeIxZ5ywwghuP6DdJCDAojiAZFQIcq2ViyvAYssysgZ6hMBKK0A7 X-Received: by 2002:a17:90a:cb15:: with SMTP id z21mr2927735pjt.87.1565253909559; Thu, 08 Aug 2019 01:45:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565253909; cv=none; d=google.com; s=arc-20160816; b=MJ0HobN3/4ufr9HsLVOFywsg8Pa1bGjEFu5fWHLf4vNSs2GZp3/C+wHjFYXUI+Z/gh R9EMVlGf+CUdsn0ldRAW7GyVlN5Q2ktv5uu1GRmowkpg5MQNpSiTJGUctZ7pBIY/MrzX M6hkPNvdoucNd3cvxHZ99E1bUOghArsovJFUnCTKYG7UGU9uNJNyOqcw0Ar7wyabSdhV nsu8LvOLERUXO6n6EcbkkSWtv+mCNzU8ZfSjbAyM3hh91gtSBkF3X7BXeev3wAVy2E68 rxMKphPnXJFvOy4DE3x3YjWfVYeB2kzYlzmXwd7dKzHq7IhPXzATG47Cl3cuVoqA72NG 4JSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=Ie3mp4NVKQiRqVScYtsW/1o05H8/mSyOmqXkJBiR/+0=; b=cfdKxrmp0RT4bw6W51ZbZ8OqxVarqmBFDaZFw2OYC7KZAn6n+6ozC3XiSEfWIc//Q+ zWhU6q3o/beKYf2TuBphzpmoFPa3SJvuU9nXt3CgkjqqAtb/LBysxxxzXV1Xh1K89SWe 6L8ut2E2615dhYxkcT4d8W9RZfNFWIMokqp/aC/qod7mZMZdiaSjIb+9etv61y9JrB2t Y/nDTGzuPbYyLmBINZaOu+qKpSZ/v3R9ftIq8ZnCUz5wXvkD3uxUGPQRaN5dG4I7EQW6 IjSYZn0/c3G6QPaHTDZSbs34N/s28HBOEP2JaWVQ7zQUYwJalLrIKUe4wSGDNw+dE779 ThNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=jED+jZHz; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 72si46986888plb.177.2019.08.08.01.44.54; Thu, 08 Aug 2019 01:45:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=jED+jZHz; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731362AbfHHInd (ORCPT + 99 others); Thu, 8 Aug 2019 04:43:33 -0400 Received: from mail.skyhub.de ([5.9.137.197]:59656 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731313AbfHHInc (ORCPT ); Thu, 8 Aug 2019 04:43:32 -0400 Received: from zn.tnic (p200300EC2F0FD700B5ECB790597D1186.dip0.t-ipconnect.de [IPv6:2003:ec:2f0f:d700:b5ec:b790:597d:1186]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id 2A65F1EC0B07; Thu, 8 Aug 2019 10:43:31 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1565253811; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:in-reply-to:in-reply-to: references:references; bh=Ie3mp4NVKQiRqVScYtsW/1o05H8/mSyOmqXkJBiR/+0=; b=jED+jZHzuEwHYoLGE4PKlPOGzHKZqTeQp4YIYdmL+g2BskOLofMJGXt1hLoZLb/5nULRPl mAW2QdoL/h1ohXSeXXBiuM6murDvrtI0Ytr61q+aic9yu+2mRChMqYPs7zkSe2x8fqnJpH WntMnSuNu3OSGZXsy9U6C8ARpEJL8z0= Date: Thu, 8 Aug 2019 10:44:16 +0200 From: Borislav Petkov To: Reinette Chatre Cc: tglx@linutronix.de, fenghua.yu@intel.com, tony.luck@intel.com, kuo-lang.tseng@intel.com, mingo@redhat.com, hpa@zytor.com, x86@kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH V2 09/10] x86/resctrl: Pseudo-lock portions of multiple resources Message-ID: <20190808084416.GC20745@zn.tnic> References: <20190807152511.GB24328@zn.tnic> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 07, 2019 at 12:23:29PM -0700, Reinette Chatre wrote: > I do not fully understand this proposal. All those goto labels take care > of the the different failures that can be encountered during the > initialization of the pseudo-lock region. Each initialization failure is > associated with a goto where it jumps to the cleanup path. The > initialization starts with the constraining of the c-states > (initializing plr->pm_reqs), but if I move that I think it will not > reduce the goto labels, just change the order because of the other > initialization done (plr->size, plr->line_size, plr->cpu). Here's one possible way to do it, pasting the whole function here as it is easier to read it this way than an incremental diff ontop. You basically cache all attributes in local variables and assign them to the plr struct only on success, at the end. This way, no goto labels and the C-states constraining, i.e., the most expensive operation, happens last, only after all the other simpler checks have succeeded. And you don't have to call pseudo_lock_cstates_relax() prematurely, when one of those easier checks fail. Makes sense? Btw, I've marked the cpu_online() check with "CPU hotplug lock?!?" question because I don't see you holding that lock with get_online_cpus()/put_online_cpus(). static int pseudo_lock_l2_l3_portions_valid(struct pseudo_lock_region *plr, struct pseudo_lock_portion *l2_p, struct pseudo_lock_portion *l3_p) { unsigned int l2_size, l3_size, size, line_size, cpu; struct rdt_domain *l2_d, *l3_d; l2_d = rdt_find_domain(l2_p->r, l2_p->d_id, NULL); if (IS_ERR_OR_NULL(l2_d)) { rdt_last_cmd_puts("Cannot locate L2 cache domain\n"); return -1; } l3_d = rdt_find_domain(l3_p->r, l3_p->d_id, NULL); if (IS_ERR_OR_NULL(l3_d)) { rdt_last_cmd_puts("Cannot locate L3 cache domain\n"); return -1; } if (!cpumask_subset(&l2_d->cpu_mask, &l3_d->cpu_mask)) { rdt_last_cmd_puts("L2 and L3 caches need to be in same hierarchy\n"); return -1; } l2_size = rdtgroup_cbm_to_size(l2_p->r, l2_d, l2_p->cbm); l3_size = rdtgroup_cbm_to_size(l3_p->r, l3_d, l3_p->cbm); if (l2_size > l3_size) { rdt_last_cmd_puts("L3 cache portion has to be same size or larger than L2 cache portion\n"); return -1; } size = l2_size; l2_size = get_cache_line_size(cpumask_first(&l2_d->cpu_mask), l2_p->r->cache_level); l3_size = get_cache_line_size(cpumask_first(&l3_d->cpu_mask), l3_p->r->cache_level); if (l2_size != l3_size) { rdt_last_cmd_puts("L2 and L3 caches have different coherency cache line sizes\n"); return -1; } line_size = l2_size; cpu = cpumask_first(&l2_d->cpu_mask); /* * CPU hotplug lock?!? */ if (!cpu_online(cpu)) { rdt_last_cmd_printf("CPU %u associated with cache not online\n", cpu); return -1; } if (!get_cache_inclusive(cpu, l3_p->r->cache_level)) { rdt_last_cmd_puts("L3 cache not inclusive\n"); return -1; } /* * All checks passed, constrain C-states: */ if (pseudo_lock_cstates_constrain(plr, &l2_d->cpu_mask)) { rdt_last_cmd_puts("Cannot limit C-states\n"); pseudo_lock_cstates_relax(plr); return -1; } plr->line_size = line_size; plr->size = size; plr->cpu = cpu; return 0; } -- Regards/Gruss, Boris. Good mailing practices for 400: avoid top-posting and trim the reply.