Received: by 2002:ac0:e350:0:0:0:0:0 with SMTP id g16csp1400420imn; Sun, 31 Jul 2022 05:43:01 -0700 (PDT) X-Google-Smtp-Source: AGRyM1seh6axDuBvRcPMPGo/UFNpkutw1bZygX0mLfTUxUGJ0wO8Ym9QFbdAhLMiNFFbpzWZImIl X-Received: by 2002:a17:907:868e:b0:72e:fac8:ce51 with SMTP id qa14-20020a170907868e00b0072efac8ce51mr9117120ejc.549.1659271380860; Sun, 31 Jul 2022 05:43:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659271380; cv=none; d=google.com; s=arc-20160816; b=ZWNAEPU6p/3LqkruahEaX1i7OCg/faYyTEJ8hfhvzAwWUVVOEePM9ZsJw2sR2Y+r0T EMYWqsalVoJ4OfpiQmXVIzsvV2y2thdOHLtNR4VxiDnANswj6wJ/r6gkv42DFIIG6koE ojmbabQTO3sZXWNk810cMhndHAO+aS2M/DbXFZeEZiF8wqy8HWodh/Tv+XsQ1pnSy+rQ LZCHtVe6pGix0E8/zEhVEb2+bFvs63YkwP5hzAS882VzZvThIdrNjvKAYjZLMypjjIHW 9q1L4LOrTZ3ND7Z6GIkJMG+6JWESjCzMcYoUew7XvBqCzWqlDB9lNLYIEPXYc4VQNRPW O9Ig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:date:from:dkim-signature; bh=8KDJgdOghTf5YMJOSTb51Tk9SBCdsaIf+xw5hxG4mmc=; b=T9QAB5opJjSzr7uEzMwvE89UTv7XL9EVO4tZbKst27GjomSz6o43q4jhYn8qYm0SUo x1qFxuGsM3ERFzTNVPbvoCWYPzkyM74+6SpAMoLEsLbxdPiKcIOJTEYj4aZ3UftTQsJK 5OoX3RFD+xQlAVqTMDkCjhXVYVCftvvPM7vz21FvVv4KdqjDxa/N7crHOWpxfF33phby gdpkhTx+Lwxv3ps1i6TQQdobnx778sSyShExgmyz4yEWxir3PWBVi2YZzcLSNbMXxoqp LnTSEeTGFj3/hGEUPjEouTxMcOOxybyZMqm9oQTDRsx5IgNsVBL+EQlBkSzI9bPJw+V3 ODgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=LaJijLLH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gs34-20020a1709072d2200b0073061fb686dsi2519565ejc.343.2022.07.31.05.42.34; Sun, 31 Jul 2022 05:43:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=LaJijLLH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236934AbiGaMhz (ORCPT + 99 others); Sun, 31 Jul 2022 08:37:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46660 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236352AbiGaMhy (ORCPT ); Sun, 31 Jul 2022 08:37:54 -0400 Received: from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com [IPv6:2a00:1450:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E6B8CDF83; Sun, 31 Jul 2022 05:37:52 -0700 (PDT) Received: by mail-ed1-x52b.google.com with SMTP id r4so2899776edi.8; Sun, 31 Jul 2022 05:37:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:date:from:from:to:cc; bh=8KDJgdOghTf5YMJOSTb51Tk9SBCdsaIf+xw5hxG4mmc=; b=LaJijLLH0bdWS+tn+3nVzYWSKs8xkHmuP/nAIRxDfCSAJyNgyyp2u3XLUTRWIHuEXL eZlUPZsqTY29fgUmvSYPBt5JE4ZO0jfMOwbm9BB23GKKsLXfQHBMSSxjHymAnN+6iKJ6 ZeTm3pXZcX/bJ9csdp3xlQvJZy0WEptShPWMJrfQckBvLZnu3PB1Q4Fbu3fsAfUwjHHv AexhTosccdx+yqdu0ThLHOujAfvjzkWmPouu6Qqi7h5ynk2qySddTmAUvdCzAWyNv6Un PLE5QpmG0JOwEAxnNNlhEphFEJ1DtggIcqJ5yzgJ39/F6Ywt4iA9f68BLIJYoXIbTQ0O i5sA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:date:from:x-gm-message-state:from:to:cc; bh=8KDJgdOghTf5YMJOSTb51Tk9SBCdsaIf+xw5hxG4mmc=; b=Q3bOet9MCAsit605Mgfn+GcFq7wf4QGrJZ0EyaeltYaD6+V7YILrIzbdoRUJXxAqmG QfU7CC0IxkjDTCeL2QrxlhQk046YkNWoCt45IruXpoe9Tq+j5rf5D2SK0X8z6jvs0PxH GJxxEVtEQ026jvvQJZZhSGrVPeqIOc4+CLWPVScNKNaMJ4fGD0IXZwJL4Gs9vXZv3YaT VX59S90m7SyJ/WHJzFCKSijgxLqpRxW3GdsyDRROa2amw5ZGVLCZlTHvpUuBRwEvJJAW gknNoT9evO2s1Iz/ENy/cXmo/2vzp6vIRMW+YYVCWcYbfiUIY5Wttx8R8cUuzBAnQpoC C99A== X-Gm-Message-State: AJIora9FN5jRDJ0ztqH7xpZxKXtgo0W8aAkVGc6qZdw5S/FQlEdM4pO8 ZGW9TOYG9NTnIVYPSmMVNsY= X-Received: by 2002:a05:6402:510c:b0:43a:e041:a371 with SMTP id m12-20020a056402510c00b0043ae041a371mr11268794edd.424.1659271071319; Sun, 31 Jul 2022 05:37:51 -0700 (PDT) Received: from krava ([83.240.61.175]) by smtp.gmail.com with ESMTPSA id f5-20020a056402160500b0043cd06bef33sm5256110edv.97.2022.07.31.05.37.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 31 Jul 2022 05:37:50 -0700 (PDT) From: Jiri Olsa X-Google-Original-From: Jiri Olsa Date: Sun, 31 Jul 2022 14:37:48 +0200 To: Ian Rogers Cc: Jiri Olsa , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Namhyung Kim , James Clark , Kees Cook , "Gustavo A. R. Silva" , Adrian Hunter , Riccardo Mancini , German Gomez , Colin Ian King , Song Liu , Dave Marchevsky , Athira Rajeev , Alexey Bayduraev , Leo Yan , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Stephane Eranian Subject: Re: [PATCH v2 0/6] Corrections to cpu map event encoding Message-ID: References: <20220614143353.1559597-1-irogers@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jul 29, 2022 at 07:28:36AM -0700, Ian Rogers wrote: > On Fri, Jul 29, 2022 at 4:35 AM Jiri Olsa wrote: > > > > On Thu, Jul 28, 2022 at 07:01:09PM -0700, Ian Rogers wrote: > > > On Fri, Jul 15, 2022 at 10:01 AM Ian Rogers wrote: > > > > > > > > On Tue, Jun 14, 2022 at 7:33 AM Ian Rogers wrote: > > > > > > > > > > A mask encoding of a cpu map is laid out as: > > > > > u16 nr > > > > > u16 long_size > > > > > unsigned long mask[]; > > > > > However, the mask may be 8-byte aligned meaning there is a 4-byte pad > > > > > after long_size. This means 32-bit and 64-bit builds see the mask as > > > > > being at different offsets. On top of this the structure is in the byte > > > > > data[] encoded as: > > > > > u16 type > > > > > char data[] > > > > > This means the mask's struct isn't the required 4 or 8 byte aligned, but > > > > > is offset by 2. Consequently the long reads and writes are causing > > > > > undefined behavior as the alignment is broken. > > > > > > > > > > These changes do minor clean up with const, visibility of functions > > > > > and using the constant time max function. It then adds 32 and 64-bit > > > > > mask encoding variants, packed to match current alignment. Taking the > > > > > address of a packed struct leads to unaligned data, so function > > > > > arguments are altered to be passed the packed struct. To compact the > > > > > mask encoding further and drop the padding, the 4-byte variant is > > > > > preferred. Finally a new range encoding is added, that reduces the > > > > > size of the common case of a range of CPUs to a single u64. > > > > > > > > > > On a 72 CPU (hyperthread) machine the original encoding of all CPUs is: > > > > > 0x9a98 [0x28]: event: 74 > > > > > . > > > > > . ... raw event: size 40 bytes > > > > > . 0000: 4a 00 00 00 00 00 28 00 01 00 02 00 08 00 00 00 J.....(......... > > > > > . 0010: 00 00 ff ff ff ff ff ff ff ff ff 00 00 00 00 00 ................ > > > > > . 0020: 00 00 00 00 00 00 00 00 ........ > > > > > > > > > > 0 0 0x9a98 [0x28]: PERF_RECORD_CPU_MAP > > > > > > > > > > Using the 4-byte encoding it is: > > > > > 0x9a98@pipe [0x20]: event: 74 > > > > > . > > > > > . ... raw event: size 32 bytes > > > > > . 0000: 4a 00 00 00 00 00 20 00 01 00 03 00 04 00 ff ff J..... ......... > > > > > . 0010: ff ff ff ff ff ff ff 00 00 00 00 00 00 00 00 00 ................ > > > > > > > > > > 0 0 0x9a98 [0x20]: PERF_RECORD_CPU_MAP > > > > > > > > > > Finally, with the range encoding it is: > > > > > 0x9ab8@pipe [0x10]: event: 74 > > > > > . > > > > > . ... raw event: size 16 bytes > > > > > . 0000: 4a 00 00 00 00 00 10 00 02 00 00 00 00 00 47 00 J.............G. > > > > > > > > > > 0 0 0x9ab8 [0x10]: PERF_RECORD_CPU_MAP > > > > > > > > > > v2. Fixes a bug in the size computation of the update header > > > > > introduced by the last patch (Add range data encoding) and caught > > > > > by address sanitizer. > > > > > > > > > > Ian Rogers (6): > > > > > perf cpumap: Const map for max > > > > > perf cpumap: Synthetic events and const/static > > > > > perf cpumap: Compute mask size in constant time > > > > > perf cpumap: Fix alignment for masks in event encoding > > > > > perf events: Prefer union over variable length array > > > > > perf cpumap: Add range data encoding > > > > > > > > Ping. There was some feedback on this change but nothing to create a > > > > v3. Feedback/acked-by/reviewed-by appreciated. > > > > > > Ping. Feedback appreciated. > > > > hi, > > there's some unanswered feedback: > > https://lore.kernel.org/linux-perf-users/YrwY3SP+jsTwrRBw@krava/ > > > > jirka > > Thanks Jirka, > > Was there a comment in particular? My reply was here: > https://lore.kernel.org/linux-perf-users/CAP-5=fU=BpP4OT2axZLSfRnKxQxmv-HXj8khBgmx3XQMS+abgA@mail.gmail.com/ > I double checked, everyone of your comments was answered. ugh sorry, seems it did not get into my inbox for some reason jirka