Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp1209113rwi; Thu, 20 Oct 2022 09:49:51 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6QeytYK8Qu0Z3zDxbzEuXwc0fx51iE9IRYMmTCUfAIXsZ33Tibd/rHwaqXcZmEemFI6rUG X-Received: by 2002:a17:907:78d:b0:740:33e1:998 with SMTP id xd13-20020a170907078d00b0074033e10998mr12132263ejb.162.1666284590800; Thu, 20 Oct 2022 09:49:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666284590; cv=none; d=google.com; s=arc-20160816; b=Ia0UmJZf8v4OAMDlrhrmGkvU/IXjUGZWoY/lwbdRAcRtjo3X0DQTsc+OU/+xzlvI18 kzd7sxavHP3qxxbMo52m7TMrQpZB+/COml6zxLlnrYt1lbT4bLimBgzRVvLu2LbGW0Vp QqDuh6XbrMOulNKWcY2DwicXgkv1HZrZxs6rGdZldj5akQYgbLsEViQl2YmL40cPb7O3 0c7PKweiRfHq9+EvC/ciRhlhD0ddJ0JZPUedmsx7xvsA6eAtsfQ+hNoMYIXZIjemno4e 7brLnsY2Yglc9GTIiVhMECaJGP6w3SNYnQV7YzZW2BySbQRJ82DvYzKIsMkfj4ZwgGBm uZaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=6c56fZ5kerOQ5aIM75vB4dMcPlUkfVpQAx4Ufxtjbdk=; b=IrAyNXvKe50pzPj7rT/GrdMDBUdc3NdEA0G2NBq0AUzb1dQ1QFu5zLgQHAf5POzob4 XmKOusVvFMO2kDtaNGrQVtQ487eMpdus9pMEPD52+RUTeJLjSwvZs7ps52XK8J6BHX4O mxuyGmOoe33VcoARWCODScv5W5gMioezfMqfAWIGBEvPUn4wMZ2s7szgW+6bV+SMdzIu KKACky85me/f2beUqXtr1SvSfgNgeziM6N58AQKzRT75LavcLAEXJY00NW6ZmIqXnOQb LAb5ts6JEACnU5g+92eGBza3jAsHTOyvHrqTQ+8tP6DvVWjwFG7qj/X8ok0SwV0lpO+p jp1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@zx2c4.com header.s=20210105 header.b=bHnUKadW; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=zx2c4.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b15-20020a056402350f00b0045bfaaab6d1si18328246edd.48.2022.10.20.09.49.25; Thu, 20 Oct 2022 09:49:50 -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=@zx2c4.com header.s=20210105 header.b=bHnUKadW; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=zx2c4.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229763AbiJTQ21 (ORCPT + 99 others); Thu, 20 Oct 2022 12:28:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44526 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229494AbiJTQ2Z (ORCPT ); Thu, 20 Oct 2022 12:28:25 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EDBC62E9D6; Thu, 20 Oct 2022 09:28:24 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id 1FA1DCE26F9; Thu, 20 Oct 2022 16:28:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DEFFCC433B5; Thu, 20 Oct 2022 16:28:20 +0000 (UTC) Authentication-Results: smtp.kernel.org; dkim=pass (1024-bit key) header.d=zx2c4.com header.i=@zx2c4.com header.b="bHnUKadW" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zx2c4.com; s=20210105; t=1666283298; 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: in-reply-to:in-reply-to:references:references; bh=6c56fZ5kerOQ5aIM75vB4dMcPlUkfVpQAx4Ufxtjbdk=; b=bHnUKadWsAUlF5xfxV4eJ7eZeUVZuzHbvjXnv8KT1YFZWheHixIoOHRqDj2dXiKv1ZfhtE rWnMSwzb4Rl5GOjvYp1Z+Oe8RqGPVPijCuWtPNwERamJKyG1MaLXSQlAHuf3Wjc+lOZoBK S5+FEFBAf/vloGUaKYuXzbHoRjiMq7A= Received: by mail.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id d41a3611 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Thu, 20 Oct 2022 16:28:18 +0000 (UTC) Received: by mail-ua1-f49.google.com with SMTP id h25so9959512uao.13; Thu, 20 Oct 2022 09:28:17 -0700 (PDT) X-Gm-Message-State: ACrzQf1kcoYSL0Tlbchk3/rY1JIE/wtGlZhyMLtJupM1Jb9Iby5xvxXw fcYATk9Pz+ZShih3Dgi3FetbUeSc8NSENnuQfcM= X-Received: by 2002:a67:ec47:0:b0:3a9:682c:bc5c with SMTP id z7-20020a67ec47000000b003a9682cbc5cmr7410097vso.70.1666283296983; Thu, 20 Oct 2022 09:28:16 -0700 (PDT) MIME-Version: 1.0 References: <20221020000356.177CDC433C1@smtp.kernel.org> In-Reply-To: From: "Jason A. Donenfeld" Date: Thu, 20 Oct 2022 10:28:06 -0600 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH -mm] -funsigned-char, x86: make struct p4_event_bind::cntr signed array To: Alexey Dobriyan Cc: akpm@linux-foundation.org, linux-kernel@vger.kernel.org, mm-commits@vger.kernel.org, torvalds@linux-foundation.org, masahiroy@kernel.org, keescook@chromium.org, gregkh@linuxfoundation.org, andriy.shevchenko@linux.intel.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-6.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 Thu, Oct 20, 2022 at 3:49 AM Alexey Dobriyan wrote: > > struct p4_event_bind::cntr[][] should be signed because of > the following code: > > int i, j; > for (i = 0; i < P4_CNTR_LIMIT; i++) { > ===> j = bind->cntr[thread][i]; > if (j != -1 && !test_bit(j, used_mask)) > return j; > } > > Making this member unsigned will make "j" 255 and fail "j != -1" > comparison. > > Signed-off-by: Alexey Dobriyan Nice catch. Reviewed-by: Jason A. Donenfeld > arch/x86/events/intel/p4.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > --- a/arch/x86/events/intel/p4.c > +++ b/arch/x86/events/intel/p4.c > @@ -24,7 +24,7 @@ struct p4_event_bind { > unsigned int escr_msr[2]; /* ESCR MSR for this event */ > unsigned int escr_emask; /* valid ESCR EventMask bits */ > unsigned int shared; /* event is shared across threads */ > - char cntr[2][P4_CNTR_LIMIT]; /* counter index (offset), -1 on absence */ > + signed char cntr[2][P4_CNTR_LIMIT]; /* counter index (offset), -1 on absence */ > }; This is fine, but I wonder if this is a good occasion to use `s8` instead? Jason