Received: by 2002:a25:2c96:0:0:0:0:0 with SMTP id s144csp196794ybs; Tue, 26 May 2020 07:05:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyFElsQBhaoHaxc28pseVk2eY2mQd5zC4Mgp9RMicTaNLZv70THVeFiK7+Y8Vbl+eA7haBy X-Received: by 2002:a17:907:2065:: with SMTP id qp5mr1263344ejb.136.1590501946318; Tue, 26 May 2020 07:05:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590501946; cv=none; d=google.com; s=arc-20160816; b=ZKFXJAjxh0iaK1tn7WEaeCV0PI5BmqMf1yMOCO/+O3oOBx55Tww8rwd/teZELF6jka xiZ3Ytpj8mxRzXWoYKbX0ZonkdFMpo5hM39hfu1epHNkpswwRCwopYkiTZPaYUjZQVxI fvihxyl0U/sSVq0Y8s6qHmKvPF+CvDbQ9TPkgr3TzVe5gx3vH76h+ejtrqfM3XUgrp9p 2MxiVR60kszGCVs4illLiyz3o2s/5RTa5qsb0VbYgn3cPzyBkN3pkke87DlO4fl29zKq afXA6KUsIW5GJatwWMbl0E6ZrX5UTrsVIkrpu2G/lC2UmlXqp7twZG4f82Bt/AsbEyTD lLkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=8qYnwrG7NJt4C9R5NuCos5+0oGWAZcdrxYJA8FsHuE0=; b=CEkw1A2APSh4wAFFG8wXo+e7qUAXk5YQcL6a58tri5TGUFcLSxT6w2Q4lqHYX3dOPw Lr2FpoZb5kLQf1ayNHYVYX22DJb2CAMVZjFoHWbxWfaB0tl5L6vmFfyhI4hDdbiZrvSz pA/wfQ1SS6BSE3M/Wwa1A7yi5rbQSTxS5Aa2diZGrU2OyW1XJIdQ2hb241pFA3ZjnEBQ IIlCABkSSpzHqOFSJXYWnlyJTUsiWyu/9M+yqzJioC6Drvk3jg3KqAY6MkbH9sWeFjya jojS7WleymRyBTEZv3CZ9BODCz2k7UNSFLpMbcOuEH37bhipLfpw4bAAuta10hC7bHpi 3UMg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k11si11032899ejz.137.2020.05.26.07.05.19; Tue, 26 May 2020 07:05:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388971AbgEZNlT (ORCPT + 99 others); Tue, 26 May 2020 09:41:19 -0400 Received: from foss.arm.com ([217.140.110.172]:50968 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388934AbgEZNlR (ORCPT ); Tue, 26 May 2020 09:41:17 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id EC9C71FB; Tue, 26 May 2020 06:41:16 -0700 (PDT) Received: from melchizedek.cambridge.arm.com (melchizedek.cambridge.arm.com [10.1.196.50]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 7734F3F6C4; Tue, 26 May 2020 06:41:15 -0700 (PDT) From: James Morse To: x86@kernel.org, linux-kernel@vger.kernel.org Cc: Fenghua Yu , Reinette Chatre , Thomas Gleixner , Ingo Molnar , Borislav Petkov , H Peter Anvin , Babu Moger , James Morse Subject: [PATCH v4 04/10] x86/resctrl: use container_of() in delayed_work handlers Date: Tue, 26 May 2020 14:40:53 +0100 Message-Id: <20200526134059.1690-5-james.morse@arm.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20200526134059.1690-1-james.morse@arm.com> References: <20200526134059.1690-1-james.morse@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org mbm_handle_overflow() and cqm_handle_limbo() are both provided with the domain's work_struct when called, but use get_domain_from_cpu() to find the domain, along with the appropriate error handling. container_of() saves some list walking and bitmap testing, use that instead. Signed-off-by: James Morse Reviewed-by: Reinette Chatre --- arch/x86/kernel/cpu/resctrl/monitor.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/resctrl/monitor.c index d6b92d7487a7..54dffe574e67 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -477,19 +477,13 @@ void cqm_handle_limbo(struct work_struct *work) mutex_lock(&rdtgroup_mutex); r = &rdt_resources_all[RDT_RESOURCE_L3]; - d = get_domain_from_cpu(cpu, r); - - if (!d) { - pr_warn_once("Failure to get domain for limbo worker\n"); - goto out_unlock; - } + d = container_of(work, struct rdt_domain, cqm_limbo.work); __check_limbo(d, false); if (has_busy_rmid(r, d)) schedule_delayed_work_on(cpu, &d->cqm_limbo, delay); -out_unlock: mutex_unlock(&rdtgroup_mutex); } @@ -519,10 +513,7 @@ void mbm_handle_overflow(struct work_struct *work) goto out_unlock; r = &rdt_resources_all[RDT_RESOURCE_L3]; - - d = get_domain_from_cpu(cpu, r); - if (!d) - goto out_unlock; + d = container_of(work, struct rdt_domain, mbm_over.work); list_for_each_entry(prgrp, &rdt_all_groups, rdtgroup_list) { mbm_update(r, d, prgrp->mon.rmid); -- 2.19.1