From patchwork Wed May 9 17:13:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Hansen X-Patchwork-Id: 10390233 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7C72460236 for ; Wed, 9 May 2018 17:18:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6D3E52851A for ; Wed, 9 May 2018 17:18:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 61CDC2851E; Wed, 9 May 2018 17:18:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BE2A42851A for ; Wed, 9 May 2018 17:18:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7B84F6B053E; Wed, 9 May 2018 13:18:48 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 765026B0541; Wed, 9 May 2018 13:18:48 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 552966B0540; Wed, 9 May 2018 13:18:48 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl0-f70.google.com (mail-pl0-f70.google.com [209.85.160.70]) by kanga.kvack.org (Postfix) with ESMTP id 07D216B053E for ; Wed, 9 May 2018 13:18:48 -0400 (EDT) Received: by mail-pl0-f70.google.com with SMTP id t5-v6so4066143ply.13 for ; Wed, 09 May 2018 10:18:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:subject:to:cc :from:date:references:in-reply-to:message-id; bh=xG0opHvlB6glm+TMiTkUNZG9zy0Iz4xi6ylH4ZM1kNw=; b=nb11mCgxBwqV6DmomBMftxYFA6zJj1A/FTh2LEH0mXSlSAPRIkKCIt8keBX41VZfF4 1pIYFLDkiuoK9UZtoXiswh9Xw0R8PSyMMj/Sb/jEOhhDjzMelYX4jd0pvoTOwI2cN6A5 OB2wH0SKmk1z6mRq2RpDkslQXxWxaAxdDChHZ9II+p0uefLeNqTz0oB97V7CqhxidPFS cLfx8J7iElAUbgBX5BxMVqoVFoYCEh2P7hBDYNFlGwoeir/M2fHBDhaxVi8W0OHJ5KQh UIbK60EQC00fWK/uHZF4MZjE6MRGFXlnL+tkvZzYCI5WvDvXzvnNZ+C5FG9ROa5Lx1Nw TggQ== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of dave.hansen@linux.intel.com designates 192.55.52.115 as permitted sender) smtp.mailfrom=dave.hansen@linux.intel.com X-Gm-Message-State: ALQs6tDR/EMnIOGqaryij3eiqu3BFzKyE2MeMGeHkZ/L38MnG3bpei9O TOBenNfDMLbl58TrQKCGyIypuG5YTTIqCp5mdP4zBwfPVNCAG8s87y0Ym/TKF9mDT0mNP6cr2ZZ Og0Ec8GmN6LYxAtJ+DbhmpGIjJTjHuI3GMau9BYX1JBWo5pgu30i6gXuNGTpM+eBO0g== X-Received: by 10.98.218.23 with SMTP id c23mr37047942pfh.128.1525886327725; Wed, 09 May 2018 10:18:47 -0700 (PDT) X-Google-Smtp-Source: AB8JxZohf+AOkZLh4T4yGQABukp1pLi6S5Dqjrmphru0sCUBmp1eGJU/pl8zuH+C8rE1JoZdVmZE X-Received: by 10.98.218.23 with SMTP id c23mr37047897pfh.128.1525886326943; Wed, 09 May 2018 10:18:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525886326; cv=none; d=google.com; s=arc-20160816; b=H73e7E1yzUSXGdDbDG+TUVZKV7CEi8uH7AivCz0GX10WwyS7oJ29A0YuuGoUkJI61J zO3xJ4fBTJpcTsVzFM1HX87maTa9QTNRXvBGop9Y1n07Rc1fp4QhrSmmH2d4sEsxF1JN 1AwGY/4P6nl5ChedcPOkQu4iB5rkoEVFwooodKoFDgdkkWzq59Enzfxgu+njcxB4KcAt /t1A5IsFMQKtU7ujZ+k0yKjS+RUXXe2OhfDyhxMsMb+btMGbdoAFeaHTQHb35uD8PBDZ tUoH+WOSaFnpUd/OL6nKqY+mGwMEtIg+97iFNDh+Tn+wrAuFZrct+tzAjQaLtA0vZchU yfvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:in-reply-to:references:date:from:cc:to:subject :arc-authentication-results; bh=xG0opHvlB6glm+TMiTkUNZG9zy0Iz4xi6ylH4ZM1kNw=; b=w7Cs+LnQm3JuN2JG1HcUhxGplNPLOAailbbxHSjuyD69zHpNEoPdn4r0pisYXtinY4 MQjYKXbYIdUspSMbGoWF4GaVZZfC/mrpPFA+WgJjaPPOjNYB2AD+pw3wEK3+885PBFPH 0+3zqQxoYphD57oCWSSwLsQPZv1NW7CIfgh1kQvXJyxkJoNS2r3y9pmMCMxnWWvJi4CZ ksY3LbstlVLm0NocPSmjRhXqIxWGJ7NJXPSmBsxYto74TceqJtfbLcg8vktTo9MWNWIy CEdK+e733CaqJDGV9ZlhmWZZH802mqDYtxp3HWPXZjuHBKVHOmud4rHub9oisjWQcarB gwKA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of dave.hansen@linux.intel.com designates 192.55.52.115 as permitted sender) smtp.mailfrom=dave.hansen@linux.intel.com Received: from mga14.intel.com (mga14.intel.com. [192.55.52.115]) by mx.google.com with ESMTPS id w5si13496895pfi.88.2018.05.09.10.18.46 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 May 2018 10:18:46 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of dave.hansen@linux.intel.com designates 192.55.52.115 as permitted sender) client-ip=192.55.52.115; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of dave.hansen@linux.intel.com designates 192.55.52.115 as permitted sender) smtp.mailfrom=dave.hansen@linux.intel.com X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 May 2018 10:18:46 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,382,1520924400"; d="scan'208";a="38056800" Received: from viggo.jf.intel.com (HELO localhost.localdomain) ([10.54.39.119]) by fmsmga007.fm.intel.com with ESMTP; 09 May 2018 10:18:45 -0700 Subject: [PATCH 02/13] x86/pkeys/selftests: Stop using assert() To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, Dave Hansen , linuxram@us.ibm.com, tglx@linutronix.de, dave.hansen@intel.com, mpe@ellerman.id.au, mingo@kernel.org, akpm@linux-foundation.org, shuah@kernel.org From: Dave Hansen Date: Wed, 09 May 2018 10:13:40 -0700 References: <20180509171336.76636D88@viggo.jf.intel.com> In-Reply-To: <20180509171336.76636D88@viggo.jf.intel.com> Message-Id: <20180509171340.E63EF7DA@viggo.jf.intel.com> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Dave Hansen If we use assert(), the program "crashes". That can be scary to users, so stop doing it. Just exit with a >0 exit code instead. Signed-off-by: Dave Hansen Cc: Ram Pai Cc: Thomas Gleixner Cc: Dave Hansen Cc: Michael Ellermen Cc: Ingo Molnar Cc: Andrew Morton Cc: Shuah Khan --- b/tools/testing/selftests/x86/protection_keys.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff -puN tools/testing/selftests/x86/protection_keys.c~pkeys-selftests-do-not-assert tools/testing/selftests/x86/protection_keys.c --- a/tools/testing/selftests/x86/protection_keys.c~pkeys-selftests-do-not-assert 2018-05-09 09:20:18.717698407 -0700 +++ b/tools/testing/selftests/x86/protection_keys.c 2018-05-09 09:20:18.720698407 -0700 @@ -72,10 +72,9 @@ extern void abort_hooks(void); test_nr, iteration_nr); \ dprintf0("errno at assert: %d", errno); \ abort_hooks(); \ - assert(condition); \ + exit(__LINE__); \ } \ } while (0) -#define raw_assert(cond) assert(cond) void cat_into_file(char *str, char *file) { @@ -87,12 +86,17 @@ void cat_into_file(char *str, char *file * these need to be raw because they are called under * pkey_assert() */ - raw_assert(fd >= 0); + if (fd < 0) { + fprintf(stderr, "error opening '%s'\n", str); + perror("error: "); + exit(__LINE__); + } + ret = write(fd, str, strlen(str)); if (ret != strlen(str)) { perror("write to file failed"); fprintf(stderr, "filename: '%s' str: '%s'\n", file, str); - raw_assert(0); + exit(__LINE__); } close(fd); }