Received: by 2002:a05:7412:518d:b0:e2:908c:2ebd with SMTP id fn13csp351450rdb; Thu, 5 Oct 2023 07:49:03 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEY/FiM6MkWRrSmfM/zEe+ji686l/zH09NfImdkJlxDBozjNUkwDOd2M1KglZrImiNCH36m X-Received: by 2002:a17:90b:4d91:b0:262:d6cb:3567 with SMTP id oj17-20020a17090b4d9100b00262d6cb3567mr5397665pjb.26.1696517342885; Thu, 05 Oct 2023 07:49:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696517342; cv=none; d=google.com; s=arc-20160816; b=dlJgElMteuX955pNm/4EYwSZdY14oDj3MUM3fngSWVwfddv0glhaJMtZ/yGqXp2dXY Qi5t8M83HygOrJM3elSqPT/ULAolV4CxK6JZF2YFOdhxBRxYQulgk1TOcTdK7W/d8vOZ qa353Wn9zn/xJtk3X2K+qNb8mvF43xvy3ZtNG++MvcYZAPGwb0zHplv8EK0Fp9AqaRPN mfmfU4A8IRb7BV41unm2L5JfZWZzKLg2ZKrTb7Ndgo+2qAUtZnguDFt5vze4I2XfA+jk ZG+hzmXFXvJdFmuuWk+6Yi0SUwKur/Sc7vbfC+uEoEzn6MpQ8fV6hToAaId/DTU/upY1 liZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:autocrypt :from:references:cc:to:content-language:subject:user-agent :mime-version:date:message-id; bh=a/vD7XD76gaEAY7Cx2XVWXrmc8mQA3X4NNhfKxYU9m8=; fh=179zhyd+nTZLSl9NVtaGbQSlTlZKul6CPsP8Qmj7/TI=; b=Zs6tIFmjswXWFJnZtPLi6rNE/6sOCUgbtGoket6OyCa2+Ng92LUHnPDuojqsgQ1HY4 E+uuMpQsp9h+OBV2K0izsPaaTf+ZyzljoqH1RXXhsf6JiSUtJxxGDhqFuqLNAL/sjy/c uHu6KmcAvkKei7TKfWw72YR4V2MTtyMyGv4fOx+KjlwahkAOyEsyXgPahgTjyAAKIkTP +23yWYrWsluIpfJnZzNFT+rd4uFgexqy+tB3e6rZJEWsjy88VhNIn+CMkwfaaSt+7Hfj 3iM0KJlqV2x2XVFKRqrXkqf99tndRXEpZAnD62MHpQCRZvgmGxsPmkJ54a6MmTw6RxUI IFXw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id ds12-20020a17090b08cc00b0026f3395cd7fsi3784773pjb.184.2023.10.05.07.49.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Oct 2023 07:49:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id CA7EE837469E; Thu, 5 Oct 2023 07:48:38 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234961AbjJEOqF (ORCPT + 99 others); Thu, 5 Oct 2023 10:46:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33484 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239009AbjJEOlc (ORCPT ); Thu, 5 Oct 2023 10:41:32 -0400 Received: from vps-vb.mhejs.net (vps-vb.mhejs.net [37.28.154.113]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BE982A5C5; Thu, 5 Oct 2023 07:16:18 -0700 (PDT) Received: from MUA by vps-vb.mhejs.net with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1qoLqs-0005vd-4Z; Thu, 05 Oct 2023 12:45:06 +0200 Message-ID: <71d4d583-9afa-4c21-8684-0285bc2b8b19@maciej.szmigiero.name> Date: Thu, 5 Oct 2023 12:45:00 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] KVM: selftests: Zero-initialize entire test_result in memslot perf test Content-Language: en-US, pl-PL To: Sean Christopherson Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Paolo Bonzini , =?UTF-8?Q?Philippe_Mathieu-Daud=C3=A9?= References: <20231005002954.2887098-1-seanjc@google.com> From: "Maciej S. Szmigiero" Autocrypt: addr=mail@maciej.szmigiero.name; keydata= xsFNBFpGusUBEADXUMM2t7y9sHhI79+2QUnDdpauIBjZDukPZArwD+sDlx5P+jxaZ13XjUQc 6oJdk+jpvKiyzlbKqlDtw/Y2Ob24tg1g/zvkHn8AVUwX+ZWWewSZ0vcwp7u/LvA+w2nJbIL1 N0/QUUdmxfkWTHhNqgkNX5hEmYqhwUPozFR0zblfD/6+XFR7VM9yT0fZPLqYLNOmGfqAXlxY m8nWmi+lxkd/PYqQQwOq6GQwxjRFEvSc09m/YPYo9hxh7a6s8hAP88YOf2PD8oBB1r5E7KGb Fv10Qss4CU/3zaiyRTExWwOJnTQdzSbtnM3S8/ZO/sL0FY/b4VLtlZzERAraxHdnPn8GgxYk oPtAqoyf52RkCabL9dsXPWYQjkwG8WEUPScHDy8Uoo6imQujshG23A99iPuXcWc/5ld9mIo/ Ee7kN50MOXwS4vCJSv0cMkVhh77CmGUv5++E/rPcbXPLTPeRVy6SHgdDhIj7elmx2Lgo0cyh uyxyBKSuzPvb61nh5EKAGL7kPqflNw7LJkInzHqKHDNu57rVuCHEx4yxcKNB4pdE2SgyPxs9 9W7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mYb8nnlQb 0fpPzYGBzK7zWIzFotuS5x1PzLYhZQFkfegyAaxys2joryhI6YNFo+BHYTfamOVfFi8QFQL5 5ZSOo27q/Ox95rwuC/n+PoJxBfqU36XBi886VV4LxuGZ8kfy0qDpL5neYtkC9w== In-Reply-To: <20231005002954.2887098-1-seanjc@google.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Thu, 05 Oct 2023 07:48:39 -0700 (PDT) On 5.10.2023 02:29, Sean Christopherson wrote: > Zero-initialize the entire test_result structure used by memslot_perf_test > instead of zeroing only the fields used to guard the pr_info() calls. > > gcc 13.2.0 is a bit overzealous and incorrectly thinks that rbestslottim's > slot_runtime may be used uninitialized. > > In file included from memslot_perf_test.c:25: > memslot_perf_test.c: In function ‘main’: > include/test_util.h:31:22: error: ‘rbestslottime.slot_runtime.tv_nsec’ may be used uninitialized [-Werror=maybe-uninitialized] > 31 | #define pr_info(...) printf(__VA_ARGS__) > | ^~~~~~~~~~~~~~~~~~~ > memslot_perf_test.c:1127:17: note: in expansion of macro ‘pr_info’ > 1127 | pr_info("Best slot setup time for the whole test area was %ld.%.9lds\n", > | ^~~~~~~ > memslot_perf_test.c:1092:28: note: ‘rbestslottime.slot_runtime.tv_nsec’ was declared here > 1092 | struct test_result rbestslottime; > | ^~~~~~~~~~~~~ > include/test_util.h:31:22: error: ‘rbestslottime.slot_runtime.tv_sec’ may be used uninitialized [-Werror=maybe-uninitialized] > 31 | #define pr_info(...) printf(__VA_ARGS__) > | ^~~~~~~~~~~~~~~~~~~ > memslot_perf_test.c:1127:17: note: in expansion of macro ‘pr_info’ > 1127 | pr_info("Best slot setup time for the whole test area was %ld.%.9lds\n", > | ^~~~~~~ > memslot_perf_test.c:1092:28: note: ‘rbestslottime.slot_runtime.tv_sec’ was declared here > 1092 | struct test_result rbestslottime; > | ^~~~~~~~~~~~~ > > That can't actually happen, at least not without the "result" structure in > test_loop() also being used uninitialized, which gcc doesn't complain > about, as writes to rbestslottime are all-or-nothing, i.e. slottimens can't > be non-zero without slot_runtime being written. > > if (!data->mem_size && > (!rbestslottime->slottimens || > result.slottimens < rbestslottime->slottimens)) > *rbestslottime = result; > > Zero-initialize the structures to make gcc happy even though this is > likely a compiler bug. The cost to do so is negligible, both in terms of > code and runtime overhead. The only downside is that the compiler won't > warn about legitimate usage of "uninitialized" data, e.g. the test could > end up consuming zeros instead of useful data. However, given that the > test is quite mature and unlikely to see substantial changes, the odds of > introducing such bugs are relatively low, whereas being able to compile > KVM selftests with -Werror detects issues on a regular basis. > > Cc: Maciej S. Szmigiero > Signed-off-by: Sean Christopherson > --- > > I don't like papering over compiler bugs, but this is causing me quite a bit of > pain, and IMO the long-term downsides are quite minimal. And I already spent > way too much time trying to figure out if there is some bizarre edge case that > gcc is detecting :-/ > Weird, but as you say, the downsides of papering over this (probable) compiler issue are small, so: Reviewed-by: Maciej S. Szmigiero Thanks, Maciej