Received: by 10.223.164.202 with SMTP id h10csp982337wrb; Tue, 7 Nov 2017 19:02:42 -0800 (PST) X-Google-Smtp-Source: ABhQp+TthpiX5bVCGoLWB7sNce0b/ScUht6iP87G47qAN1x+rOdQEbbejvccm0psa47GjISOd+bz X-Received: by 10.84.130.33 with SMTP id 30mr800074plc.131.1510110162259; Tue, 07 Nov 2017 19:02:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510110162; cv=none; d=google.com; s=arc-20160816; b=hu7PPXHvMWTZtLVvlyxL+YULfXPUPVUnVoVLG7Mi8NBGV5nxpcQrJT0L1CVxKW1w9Q RrfGPdG0mTNW8DYnBOlAc3uHB2qbWnOmfQRLS62zlamX0M82PksgyBnpkITy9QVoMVjk 2zW1ewYc66pNg5wUy12R6Et6T5D/otpPF/FgdYZjonLCTrgb1XMlYVSKEOwONH8LcQ4g gUuCReeWQCMy1GpBHsw0i1rZZB2ffIR/6oNz6VOXNP+JqTxTaxItuynhqStz4fIZC5re 603JNmy0WEFJyXTyylqq2qHs+8l3m9U8nBLgysjR0bgAJ9L8KHh7NkqK4IRsA71oOu7o Y6CQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=v/rAtKEKYtQUyPUdBjEDIAd0BYZLUxeNMVDZnzPcE+Q=; b=P9vIvJPdmRvVxvT9IVFIYpEEPPQAn2le1v6bI7ReaI4l0wFHa5NLLpvIM3DL6yMD4Y XORJCqjqV1ZZa2vn9JSjUNzg/sGuaz+pk09ZCKxCIn98yRC9P/uw7G9NgMAHfbPo2BT3 Enhaayuefk2OBTsEP3XnVLTaxflPxjwTZ5vAGYXvv6VJJrvk8ZbHIRZnf1CW5kVlUzBP 1wMDFJpKt+pUCWfvFWHj1h5+eLAcRh9zmM2z00Ex1GzMkyXe5IHyAHCiwzwdTitMEXXX kU355R0T37Bc0XjCaJpHVRTZewPmR6YctU27jhxdkXtycRo23RzXUOZrhFsMbZp80CcJ UgBg== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=synopsys.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bb5si2444350plb.22.2017.11.07.19.02.28; Tue, 07 Nov 2017 19:02:42 -0800 (PST) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=synopsys.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756514AbdKGWNY (ORCPT + 90 others); Tue, 7 Nov 2017 17:13:24 -0500 Received: from smtprelay4.synopsys.com ([198.182.47.9]:47205 "EHLO smtprelay.synopsys.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756406AbdKGWNV (ORCPT ); Tue, 7 Nov 2017 17:13:21 -0500 Received: from mailhost.synopsys.com (mailhost3.synopsys.com [10.12.238.238]) by smtprelay.synopsys.com (Postfix) with ESMTP id B8EAA24E1320; Tue, 7 Nov 2017 14:13:21 -0800 (PST) Received: from mailhost.synopsys.com (localhost [127.0.0.1]) by mailhost.synopsys.com (Postfix) with ESMTP id 9BAA79F8; Tue, 7 Nov 2017 14:13:21 -0800 (PST) Received: from US01WEHTC3.internal.synopsys.com (us01wehtc3.internal.synopsys.com [10.15.84.232]) by mailhost.synopsys.com (Postfix) with ESMTP id 87D609F7; Tue, 7 Nov 2017 14:13:21 -0800 (PST) Received: from IN01WEHTCB.internal.synopsys.com (10.144.199.106) by US01WEHTC3.internal.synopsys.com (10.15.84.232) with Microsoft SMTP Server (TLS) id 14.3.266.1; Tue, 7 Nov 2017 14:13:21 -0800 Received: from IN01WEHTCA.internal.synopsys.com (10.144.199.103) by IN01WEHTCB.internal.synopsys.com (10.144.199.105) with Microsoft SMTP Server (TLS) id 14.3.266.1; Wed, 8 Nov 2017 03:43:18 +0530 Received: from vineetg-Latitude-E7450.internal.synopsys.com (10.10.161.44) by IN01WEHTCA.internal.synopsys.com (10.144.199.243) with Microsoft SMTP Server (TLS) id 14.3.266.1; Wed, 8 Nov 2017 03:43:17 +0530 From: Vineet Gupta To: CC: , Peter Zijlstra , Vineet Gupta Subject: [PATCH 2/4] ARCv2: perf: optimize given that num counters <= 32 Date: Tue, 7 Nov 2017 14:13:02 -0800 Message-ID: <1510092784-19942-3-git-send-email-vgupta@synopsys.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1510092784-19942-1-git-send-email-vgupta@synopsys.com> References: <1510092784-19942-1-git-send-email-vgupta@synopsys.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.10.161.44] Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org use ffz primitive which maps to ARCv2 instruction, vs. non atomic __test_and_set_bit It is unlikely if we will even have more than 32 counters, but still add a BUILD_BUG to catch that Signed-off-by: Vineet Gupta --- arch/arc/kernel/perf_event.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/arch/arc/kernel/perf_event.c b/arch/arc/kernel/perf_event.c index 0eaa132a2c90..8aec462d90fb 100644 --- a/arch/arc/kernel/perf_event.c +++ b/arch/arc/kernel/perf_event.c @@ -336,15 +336,12 @@ static int arc_pmu_add(struct perf_event *event, int flags) struct hw_perf_event *hwc = &event->hw; int idx = hwc->idx; - if (__test_and_set_bit(idx, pmu_cpu->used_mask)) { - idx = find_first_zero_bit(pmu_cpu->used_mask, - arc_pmu->n_counters); - if (idx == arc_pmu->n_counters) - return -EAGAIN; - - __set_bit(idx, pmu_cpu->used_mask); - hwc->idx = idx; - } + idx = ffz(pmu_cpu->used_mask[0]); + if (idx == arc_pmu->n_counters) + return -EAGAIN; + + __set_bit(idx, pmu_cpu->used_mask); + hwc->idx = idx; write_aux_reg(ARC_REG_PCT_INDEX, idx); @@ -465,6 +462,7 @@ static int arc_pmu_device_probe(struct platform_device *pdev) pr_err("This core does not have performance counters!\n"); return -ENODEV; } + BUILD_BUG_ON(ARC_PERF_MAX_COUNTERS > 32); BUG_ON(pct_bcr.c > ARC_PERF_MAX_COUNTERS); READ_BCR(ARC_REG_CC_BUILD, cc_bcr); -- 2.7.4 From 1583513513450732729@xxx Wed Nov 08 15:49:27 +0000 2017 X-GM-THRID: 1583325737432497172 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread