Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp8266184ybc; Fri, 29 Nov 2019 07:53:17 -0800 (PST) X-Google-Smtp-Source: APXvYqwCR9j/dRI8cIDcv7SlgfZx9bsK7/xjBSab2AbgXYzcJwPjqdci+HkPBezt1tS3HtACTT5/ X-Received: by 2002:a17:907:104a:: with SMTP id oy10mr2115706ejb.324.1575042797841; Fri, 29 Nov 2019 07:53:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575042797; cv=none; d=google.com; s=arc-20160816; b=mPOrkrHTiENtvs/hcFHb2HXvMluU3HQYdamH0zNq5qeewGAnkWdqigxblV/8Fn8ZZN 1bDsjZ0GTrjqK3ou1qc46rq981SgJIZ4a12Fqo8lCFvy83r3mpyvB6ROc8SNKqGfk9R6 ZrxJ40ikX7Bg9+AOWp/co1dEKAEV+IXDXb39F2L7Y0pe/PmpkMPK/lZSWRXZ/F9Xij3E J5yI8DLVBHYTMF/O+qtb8FMVBzYrW/bR2jfMpPx75qBBUExO9KBf0t9gvQit0JwjGfs2 cZ4k8GvRq5B740az2ELlIgE5WyPEwWTfVTFj9LOM9g5R1WuY4YZRR206W0QxJ8z7u/K2 CP1A== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:organization:from:references:cc:to:subject; bh=yzrk9Vid+I5fEd6hcOHIBmjLcXLK4bVskWkD2IDwwPM=; b=qp1Ue7jxqwTokbzu987mVvKe60vk4kuB8M6gFdMRd+PZnXLR/07D/UsvaOldqCpWWI zYTCr/4H2mrewVpcvuZ2wQFaUCTQcNC1l8wEaqEDcCgdtkMashp6FNWmsz6rxnKYgqdg 7MVKap59iHCaApCbi+K+BwFu0Re4xVsta1Fr57E+juWUd9f5Q+0rMUOf9MQWjL4Lt4Ep AT9VqAT6kuXl6OoR0aNfB1dMIcxYJjzzYq95CJ+5biFTiLT4CWL0pngRqZfzrLYKezlm UQW8Ae9kJacQhIoiyQ5majpxiXHUdNQmGkLXB5wYUgl/r5u2lfg5YBC8dQANYK/n+XaA 1Ovw== 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=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z43si16724825edb.374.2019.11.29.07.52.54; Fri, 29 Nov 2019 07:53:17 -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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726934AbfK2Pt3 (ORCPT + 99 others); Fri, 29 Nov 2019 10:49:29 -0500 Received: from mga11.intel.com ([192.55.52.93]:45899 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726608AbfK2Pt3 (ORCPT ); Fri, 29 Nov 2019 10:49:29 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 29 Nov 2019 07:49:29 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,257,1571727600"; d="scan'208";a="234742526" Received: from linux.intel.com ([10.54.29.200]) by fmsmga004.fm.intel.com with ESMTP; 29 Nov 2019 07:49:28 -0800 Received: from [10.252.8.148] (abudanko-mobl.ccr.corp.intel.com [10.252.8.148]) by linux.intel.com (Postfix) with ESMTP id 686C45802B9; Fri, 29 Nov 2019 07:49:26 -0800 (PST) Subject: Re: [PATCH v3 3/3] perf record: adapt affinity to machines with #CPUs > 1K To: Jiri Olsa Cc: Arnaldo Carvalho de Melo , Namhyung Kim , Alexander Shishkin , Peter Zijlstra , Ingo Molnar , Andi Kleen , linux-kernel References: <908dbe98-7d8d-0ec1-d4ae-242f3e104979@linux.intel.com> <21bc3ad7-e1f2-68da-f004-36354a6e40ea@linux.intel.com> <20191129130710.GB14169@krava> From: Alexey Budankov Organization: Intel Corp. Message-ID: Date: Fri, 29 Nov 2019 18:49:25 +0300 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.9.1 MIME-Version: 1.0 In-Reply-To: <20191129130710.GB14169@krava> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 29.11.2019 16:07, Jiri Olsa wrote: > On Fri, Nov 29, 2019 at 01:05:26PM +0300, Alexey Budankov wrote: > > SNIP > >> # undef REASON >> #endif >> >> - CPU_ZERO(&rec->affinity_mask); >> rec->opts.affinity = PERF_AFFINITY_SYS; >> >> rec->evlist = evlist__new(); >> @@ -2499,6 +2504,14 @@ int cmd_record(int argc, const char **argv) >> >> symbol__init(NULL); >> >> + rec->affinity_mask.nbits = cpu__max_cpu(); >> + rec->affinity_mask.bits = bitmap_alloc(rec->affinity_mask.nbits); >> + if (!rec->affinity_mask.bits) { >> + pr_err("Failed to allocate thread mask for %ld cpus\n", rec->affinity_mask.nbits); >> + return -ENOMEM; >> + } >> + pr_debug2("thread mask[%ld]: empty\n", rec->affinity_mask.nbits); > > above can be done only for (rec->opts.affinity != PERF_AFFINITY_SYS) Indeed. Corrected in v4. > > >> + >> err = record__auxtrace_init(rec); >> if (err) >> goto out; >> @@ -2613,6 +2626,8 @@ int cmd_record(int argc, const char **argv) >> >> err = __cmd_record(&record, argc, argv); >> out: >> + if (rec->affinity_mask.bits) >> + bitmap_free(rec->affinity_mask.bits); >> evlist__delete(rec->evlist); >> symbol__exit(); >> auxtrace_record__free(rec->itr); >> diff --git a/tools/perf/util/mmap.c b/tools/perf/util/mmap.c >> index 30ff7aef06f2..615d05870849 100644 >> --- a/tools/perf/util/mmap.c >> +++ b/tools/perf/util/mmap.c >> @@ -219,6 +219,9 @@ static void perf_mmap__aio_munmap(struct mmap *map __maybe_unused) >> >> void mmap__munmap(struct mmap *map) >> { >> + if (map->affinity_mask.bits) >> + bitmap_free(map->affinity_mask.bits); > > you don't need to check map->affinity_mask.bits, it's checked in free Makes sense. Corrected in v4. > > jirka Thanks, Alexey