Received: by 2002:a05:7412:f584:b0:e2:908c:2ebd with SMTP id eh4csp719482rdb; Sun, 3 Sep 2023 07:29:42 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFBBy/P03nVJ+87kS1D4CJ/7oJiqDBq6Ld9lWFL6o1gtCGBRxkUxantd3YE7tsOOhoY4uTO X-Received: by 2002:a2e:8ece:0:b0:2bc:b0c3:9e8d with SMTP id e14-20020a2e8ece000000b002bcb0c39e8dmr5772633ljl.41.1693751381983; Sun, 03 Sep 2023 07:29:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693751381; cv=none; d=google.com; s=arc-20160816; b=Crw4sV6+Jc4a6SRIkMGbgihm4OGDgGk+pfrJSTbebVPY3wC5PfQoemlP2B18eAFmAn DFpQlE78Fwbqk42fVb33+RPsngB8BN+yls9oJ31U6KQZD9BrJdcrloE13SbhlgZ5NSoT uEPQY0IJgSFkjUIC3nxwqKZiCkuVxeaaMM5n0saQ2swrUa0sT/5cj3uOtg6f5Xln1Lw9 cMi6EbtWFhm1DQ6n3EFGjgaX+ufG+vFlCGdosQQaDbo73I53QCm+cO2yzdB1iKSqNEiI aAvL2KcAGmJ3Wy5ne+B0hYTa31wL7OwI5PeEPl2gNJ7STgOplDZonYLNQ6byVcCcyZhA HWzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=CKaEdjpNfqHOzKT1dRpRMbat6SQFL6yV1mMvAS58rmE=; fh=StvK+yIqAD8+XqjLENGlcWDhkLqp9B7xY2VDTjyFjRA=; b=gVomzjUaArvwYH3SIotFr/gmzcIe+VBdTgrV8wdwwNnAZ7i49HNurkVqQdIROEaOF1 tXvBQSw4KVFo657y6QXlXWESgqpMqoi8l8jf++eJ6DYFo13qEDucAT6N7hzgOT530Iz7 5mWqt2QsXXj1toOYJb0dmboXb1ViqQpgneVYH4f9WVXkNJmmhaP5hq9jVGxUQLRvAtf+ ydKmaM9xFpjnY7sK5I+x+VwPKKA/x75qYJY5EskHtzeLrwXMvdrC0DOXhc41MWqHnQrv VCrwP+f0VQwC1kn3KC1Vbza7g/2RFo4r1wfJcPA4cGC4Qob8atjQBcrmFq8Mbh5AvIXD WCuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Vr1oQPGX; 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=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id br13-20020a170906d14d00b00992969da8d7si4857394ejb.373.2023.09.03.07.29.07; Sun, 03 Sep 2023 07:29:41 -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=@intel.com header.s=Intel header.b=Vr1oQPGX; 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=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349700AbjIANMF (ORCPT + 99 others); Fri, 1 Sep 2023 09:12:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49348 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234895AbjIANMF (ORCPT ); Fri, 1 Sep 2023 09:12:05 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C4618E7E; Fri, 1 Sep 2023 06:12:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1693573922; x=1725109922; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=jXsI7NSlJRp+KqFLiENWU8UxnTN1ynoeW0TkkfW/zt4=; b=Vr1oQPGXoPt4ZjrXQRH5vpzF8y1FZtbytajNdyNW25gQa+iLqQjO99If B4lQV5wg8/NLzlNXTN9FB7HTJuoeXDqVOIMLHKq6phPqMxccXsQenx2l0 Byo1Ak1BlCdT/iF/ughC2YMKTjnKj+yUz2qGir2ZOTeajGG50B+906HxK 4Px2f9rHRiMrObzhyg3z0E3CoH0RY46/wqbuvlHiyymtKgxL78vi2ZHzx AH8Kb9YQu+/Gl1FPVaaJJIqGtTDGyxmgc8eXEbHVm5k+hRKfSMfzOxLCG UOdMUTLJ9pyGKg0CA8TSNf1wSvNh6Aj9TBRriDwzedeg6PSjJaDxgLFvC g==; X-IronPort-AV: E=McAfee;i="6600,9927,10819"; a="376147306" X-IronPort-AV: E=Sophos;i="6.02,219,1688454000"; d="scan'208";a="376147306" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Sep 2023 06:12:02 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10819"; a="716764090" X-IronPort-AV: E=Sophos;i="6.02,219,1688454000"; d="scan'208";a="716764090" Received: from rawskaal-mobl.ger.corp.intel.com (HELO wieczorr-mobl1.intel.com) ([10.213.0.136]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Sep 2023 06:11:59 -0700 From: Wieczor-Retman Maciej To: shuah@kernel.org, fenghua.yu@intel.com, reinette.chatre@intel.com Cc: ilpo.jarvinen@linux.intel.com, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH v3 0/2] selftests/resctrl: Bug fix and optimization Date: Fri, 1 Sep 2023 15:11:34 +0200 Message-ID: X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE 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 Write_schemata() uses fprintf() to write a bitmask into a schemata file inside resctrl FS. It checks fprintf() return value but it doesn't check fclose() return value. Error codes from fprintf() such as write errors, are buffered and flushed back to the user only after fclose() is executed which means any invalid bitmask can be written into the schemata file. Rewrite write_schemata() to use syscalls instead of stdio file operations to avoid the buffering. The resctrlfs.c file defines functions that interact with the resctrl FS while resctrl_val.c file defines functions that perform measurements on the cache. Run_benchmark() fits logically into the second file before resctrl_val() function that uses it. Move run_benchmark() from resctrlfs.c to resctrl_val.c and remove redundant part of the kernel-doc comment. Make run_benchmark() static and remove it from the header file. Series is based on kselftest next branch. Changelog v3: - Use snprintf() return value instead of strlen() in write_schemata(). (Ilpo) - Make run_benchmark() static and remove it from the header file. (Reinette) - Added Ilpo's reviewed-by tag to Patch 2/2. - Patch messages and cover letter rewording. Changelog v2: - Change sprintf() to snprintf() in write_schemata(). - Redo write_schemata() with syscalls instead of stdio functions. - Fix typos and missing dots in patch messages. - Branch printf attribute patch to a separate series. [v1] https://lore.kernel.org/all/cover.1692880423.git.maciej.wieczor-retman@intel.com/ [v2] https://lore.kernel.org/all/cover.1693213468.git.maciej.wieczor-retman@intel.com/ Wieczor-Retman Maciej (2): selftests/resctrl: Fix schemata write error check selftests/resctrl: Move run_benchmark() to a more fitting file tools/testing/selftests/resctrl/resctrl.h | 1 - tools/testing/selftests/resctrl/resctrl_val.c | 50 ++++++++++++ tools/testing/selftests/resctrl/resctrlfs.c | 79 ++++--------------- 3 files changed, 65 insertions(+), 65 deletions(-) base-commit: 9b1db732866bee060b9bca9493e5ebf5e8874c48 -- 2.42.0