Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp2737415ybc; Mon, 25 Nov 2019 03:23:18 -0800 (PST) X-Google-Smtp-Source: APXvYqzMyNuNYIoB1FE2YptMqHnaB9XBRbxKAvDtVHe6F7dVSHhjasUziqC6Y399+PrXGz360X5l X-Received: by 2002:a17:906:d795:: with SMTP id pj21mr37450518ejb.44.1574680998138; Mon, 25 Nov 2019 03:23:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574680998; cv=none; d=google.com; s=arc-20160816; b=ZRRQOf2a9p9j0K3pobnLNxUPqlecuLN6i97KcX1+RMKyRyxDdKvNUglxN1Azrwqm66 SXay0/mZW99w6IteXB/V4H78PWemVPUxbBMAF+ZfWbQk2nSJxQAGEh+R2fTb0h3JYsKy 61oTV/Oeo5Y51Zw3J5wy+mxK3uKLZIEFgbeLF3kesUmKywNkUjm1D3WWi9NMKsMt9eDb hTa6bE9iski2LHYXdMAkLPTFi8JTNHDqZlqo8c0sYlB+D2qF72KTEsPD65nWvLowsSyG OUgnwq6FUQmVMNWRExSTAK4flsq0BhqNZVf/p7Z754wdGOxmkNYcFvqmwjuVM8VDt3A9 lL7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:user-agent:in-reply-to:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=Xa2EnHdNdPylvQ5G4EeatVQ72rlUf1Gu0qzI0xrlkt0=; b=Cic1MD+t5HqFJhM14MfIIAlTCrKtUOk9m7H3PoSvgswbNXJG0zVYDNzoT6fCVSFZbd 2Ga8bWiF0zcpNBW0XA6L4wfa1DkivHcKc/C4t1kiO8vpgSjQuXIcMJC+uKJ27W0u1tSm oVe/13Z1QPYuKnuaDPkyIp3TFoJUlQFPzwZOAPAv8bv0qCLFALXSxK0XYMSC5gsEe055 C2wD1ZZacJ45CoXOVY7YB6vPObqEpd0bCbXeHUFX61Kcv5kUv7Jn6AlOnwSyM+stJoyf wQCZq/UTJA88Hif/o3/USw+bbBk2goIUC6KhfQyiujgUFNdUwRpVWS2QpGqDhzjWAIpK 23NQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=doiyTXQ4; 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w26si4276238eju.48.2019.11.25.03.22.53; Mon, 25 Nov 2019 03:23:18 -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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=doiyTXQ4; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727670AbfKYLVb (ORCPT + 99 others); Mon, 25 Nov 2019 06:21:31 -0500 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:56472 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727495AbfKYLVb (ORCPT ); Mon, 25 Nov 2019 06:21:31 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1574680889; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Xa2EnHdNdPylvQ5G4EeatVQ72rlUf1Gu0qzI0xrlkt0=; b=doiyTXQ4I4IYAKReENRzVjljE9D1U4JkIBgOtgQNZyTJeGmDoPIyuv3V53XNl/1jz8zdB+ onQZvn9ZnUfAWGJ3MBLS49wyeHnmQDjZDPP5SrlMLuEn2SuEKqxaM2JNtZge6JMEsfennk xLNEz77qhVPXJ98BbXf7HROCdI71DRQ= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-192-E5ZoiKzUMT2fAjAH9kPJmQ-1; Mon, 25 Nov 2019 06:21:26 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D970A804369; Mon, 25 Nov 2019 11:21:24 +0000 (UTC) Received: from krava (unknown [10.43.17.48]) by smtp.corp.redhat.com (Postfix) with SMTP id 3AA2C19C69; Mon, 25 Nov 2019 11:21:23 +0000 (UTC) Date: Mon, 25 Nov 2019 12:21:22 +0100 From: Jiri Olsa To: Alexey Budankov Cc: Arnaldo Carvalho de Melo , Namhyung Kim , Alexander Shishkin , Peter Zijlstra , Ingo Molnar , Andi Kleen , linux-kernel Subject: Re: [PATCH v2 3/3] perf record: adapt affinity to machines with #CPUs > 1K Message-ID: <20191125112122.GA1201@krava> References: <69bd0062-0f9e-889b-b7ef-0d97d257569b@linux.intel.com> <20191125094220.GC4675@krava> <9b9209ce-ba61-824f-9443-3909991ff222@linux.intel.com> MIME-Version: 1.0 In-Reply-To: <9b9209ce-ba61-824f-9443-3909991ff222@linux.intel.com> User-Agent: Mutt/1.12.1 (2019-06-15) X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: E5ZoiKzUMT2fAjAH9kPJmQ-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Nov 25, 2019 at 02:13:20PM +0300, Alexey Budankov wrote: > On 25.11.2019 12:42, Jiri Olsa wrote: > > On Mon, Nov 25, 2019 at 09:08:57AM +0300, Alexey Budankov wrote: > >=20 > > SNIP > >=20 > >> -static void perf_mmap__setup_affinity_mask(struct mmap *map, struct m= map_params *mp) > >> +static int perf_mmap__setup_affinity_mask(struct mmap *map, struct mm= ap_params *mp) > >> { > >> -=09CPU_ZERO(&map->affinity_mask); > >> +=09map->affinity_mask.nbits =3D cpu__max_cpu(); > >> +=09map->affinity_mask.bits =3D bitmap_alloc(map->affinity_mask.nbits)= ; > >> +=09if (!map->affinity_mask.bits) > >> +=09=09return -1; > >> + > >> =09if (mp->affinity =3D=3D PERF_AFFINITY_NODE && cpu__max_node() > 1) > >> =09=09build_node_mask(cpu__get_node(map->core.cpu), &map->affinity_ma= sk); > >> =09else if (mp->affinity =3D=3D PERF_AFFINITY_CPU) > >> -=09=09CPU_SET(map->core.cpu, &map->affinity_mask); > >> +=09=09set_bit(map->core.cpu, map->affinity_mask.bits); > >> + > >> +=09return 0; > >> } > >> =20 > >> +#define MASK_SIZE 1023 > >> int mmap__mmap(struct mmap *map, struct mmap_params *mp, int fd, int = cpu) > >> { > >> +=09char mask[MASK_SIZE + 1] =3D {0}; > >=20 > > does this need to be initialized? >=20 > This is to make sure the message is zero terminated for vfprintf call() hum AFAICS it's used only in bitmap_scnprintf, which should terminate the string properly jirka >=20 > >=20 > >> + > >> =09if (perf_mmap__mmap(&map->core, &mp->core, fd, cpu)) { > >> =09=09pr_debug2("failed to mmap perf event ring buffer, error %d\n", > >> =09=09=09 errno); > >> =09=09return -1; > >> =09} > >> =20 > >> -=09perf_mmap__setup_affinity_mask(map, mp); > >> +=09if (perf_mmap__setup_affinity_mask(map, mp)) { > >> +=09=09pr_debug2("failed to alloc mmap affinity mask, error %d\n", > >> +=09=09=09 errno); > >> +=09=09return -1; > >> +=09} > >> +=09bitmap_scnprintf(map->affinity_mask.bits, map->affinity_mask.nbits= , mask, MASK_SIZE); > >> +=09pr_debug2("%p: mmap mask[%ld]: %s\n", map, map->affinity_mask.nbit= s, mask); > >=20 > > the bitmap_scnprintf could be called only for debug case, right? >=20 > Right. It is required to prepare debug message. >=20 > >=20 > > =09if (version >=3D 2) { > > =09=09bitmap_scnprintf(map->affinity_mask.bits, map->affinity_mask.nbit= s, mask, MASK_SIZE); > > =09=09pr_debug2("%p: mmap mask[%ld]: %s\n", map, map->affinity_mask.nbi= ts, mask); > > =09} > >=20 > > ditto int the record__adjust_affinity function > >=20 > > jirka > >=20 > >=20 >=20 > ~Alexey >=20