From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,HK_RANDOM_FROM,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4AE3AC433E0 for ; Tue, 26 Jan 2021 16:33:39 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id F3AE622210 for ; Tue, 26 Jan 2021 16:33:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F3AE622210 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6423389B12; Tue, 26 Jan 2021 16:33:38 +0000 (UTC) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by gabe.freedesktop.org (Postfix) with ESMTPS id 799C989B12; Tue, 26 Jan 2021 16:33:37 +0000 (UTC) IronPort-SDR: o+6eZPMk1h7/zWJ42z8JI8WWoSYovxPc2qXyVEhmzCDT+lOF898oJIuGQBhOXH6t+PV8g/Us5I hrx6MCXTeMzA== X-IronPort-AV: E=McAfee;i="6000,8403,9876"; a="167601859" X-IronPort-AV: E=Sophos;i="5.79,375,1602572400"; d="scan'208";a="167601859" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jan 2021 08:33:36 -0800 IronPort-SDR: 8i1MhzqDs15j/TWqrmpv7T8VxptsaaraeDJVbqceGdFVkXZngmt5Q1VFmbHRF/vEfpeRu61wkv ykIIfY/uJWZw== X-IronPort-AV: E=Sophos;i="5.79,375,1602572400"; d="scan'208";a="362044487" Received: from jackedwa-mobl.ger.corp.intel.com (HELO [10.214.230.137]) ([10.214.230.137]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jan 2021 08:33:34 -0800 To: Chris Wilson , intel-gfx@lists.freedesktop.org References: <20210126130505.2938391-1-chris@chris-wilson.co.uk> From: Tvrtko Ursulin Organization: Intel Corporation UK Plc Message-ID: <331b98b3-8ff8-5f58-6994-4561cb0ca244@linux.intel.com> Date: Tue, 26 Jan 2021 16:33:31 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.5.0 MIME-Version: 1.0 In-Reply-To: <20210126130505.2938391-1-chris@chris-wilson.co.uk> Content-Language: en-US Subject: Re: [Intel-gfx] [igt-dev] [PATCH i-g-t 1/2] i915/sysfs_client: Ignore clients being closed as we read their sysfs X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: igt-dev@lists.freedesktop.org Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" On 26/01/2021 13:05, Chris Wilson wrote: > An earlier client from an old test may still be lingering and disappear > as we scan the sysfs. Be graceful and let it go without tripping over it. > > Signed-off-by: Chris Wilson > --- > tests/i915/sysfs_clients.c | 19 +++++++++---------- > 1 file changed, 9 insertions(+), 10 deletions(-) > > diff --git a/tests/i915/sysfs_clients.c b/tests/i915/sysfs_clients.c > index 6be52c04f..a3a1f81e1 100644 > --- a/tests/i915/sysfs_clients.c > +++ b/tests/i915/sysfs_clients.c > @@ -62,11 +62,13 @@ > > static void strterm(char *s, int len) > { > - igt_assert(len > 0); > - > - s[len] = '\0'; > - if (s[len - 1] == '\n') > - s[len - 1] = '\0'; > + if (len < 0) { > + *s = '\0'; > + } else { > + s[len] = '\0'; > + if (s[len - 1] == '\n') > + s[len - 1] = '\0'; > + } > } > > static void pidname(int i915, int clients) > @@ -78,7 +80,6 @@ static void pidname(int i915, int clients) > long count; > pid_t pid; > DIR *dir; > - int len; > > dir = fdopendir(dup(clients)); > igt_assert(dir); > @@ -90,13 +91,11 @@ static void pidname(int i915, int clients) > continue; > > snprintf(buf, sizeof(buf), "%s/name", de->d_name); > - len = igt_sysfs_read(clients, buf, buf, sizeof(buf) - 1); > - igt_assert_f(len > 0, "failed to open '%s/name'\n", de->d_name); > - strterm(buf, len); > + strterm(buf, igt_sysfs_read(clients, buf, buf, sizeof(buf) - 1)); > igt_debug("%s: %s\n", de->d_name, buf); > > /* Ignore closed clients created by drm_driver_open() */ > - if (*buf == '<') > + if (*buf == '\0' || *buf == '<') > continue; > > close(me); > Reviewed-by: Tvrtko Ursulin Regards, Tvrtko _______________________________________________ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx