From patchwork Sun Jun 17 01:59:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 10468171 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 146C2603B4 for ; Sun, 17 Jun 2018 02:01:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0429028BC1 for ; Sun, 17 Jun 2018 02:01:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EA4BA28BDB; Sun, 17 Jun 2018 02:01:01 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,T_DKIM_INVALID 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 7804728BC1 for ; Sun, 17 Jun 2018 02:01:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7258A6B0006; Sat, 16 Jun 2018 22:01:00 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 6AC356B0008; Sat, 16 Jun 2018 22:01:00 -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 54C046B0007; Sat, 16 Jun 2018 22:01:00 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl0-f69.google.com (mail-pl0-f69.google.com [209.85.160.69]) by kanga.kvack.org (Postfix) with ESMTP id 0D9466B0005 for ; Sat, 16 Jun 2018 22:01:00 -0400 (EDT) Received: by mail-pl0-f69.google.com with SMTP id w6-v6so7700471plp.14 for ; Sat, 16 Jun 2018 19:01:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references; bh=nEu/iSteNkAMtQpngBIONZNFiPmqdnQM7MosSEs/KsA=; b=lCwQm040qjcUkn0ohqIrsanOn75AZ072KOnRiRDePWOnBSbsxhcdraieaSF3ymiXi6 JurscYdJotzZ6aCCr4of4H3HH8hyWiTAnN61OMxD0ffYDnmfcB1yolOHGwqMMlvgeifD t14I82dyRW3Wcf+bm91umR04vj6GT67bIeObAKUhR0vzl2p8VVyIczuAciOK+wp/8ULq e1m1an5yNO0CrE2raUSTGSxDUVs8+Q2OfzlFIrofrIUSYYL7x+oyQijhor4QwSjcCXQ+ a93fqbeMgW/E0xzKP8abN1CyhAQVX1YYPhdQJPYnMOFpKdA1Gby6SYoB786kYmr+Qhr1 JCyQ== X-Gm-Message-State: APt69E12OI4lhaRWXLpTSL5bV0GMeMiNfoGys+IAj3c+RJLf2JOguc93 /AKRfLSMx0tmS8QLKXzu9gwJDeeFcvCtwv5joxf7eCt9TZJcoQ06Jmh9ttLULF34wOc13X8FxW2 uVAkJvgwMR3uczIInWINm9/Jd7WDSQXq2KP2OWTgco14/PoxtMrX+g4O9I37LN/lWnQ== X-Received: by 2002:a63:7e1b:: with SMTP id z27-v6mr6607053pgc.65.1529200859631; Sat, 16 Jun 2018 19:00:59 -0700 (PDT) X-Google-Smtp-Source: ADUXVKI87KRRSYkXhmY5RZsAY7fKNze5DVJmB8Lu3ftFrV1aSONeG0BtDUuVu7y+0J9pQRi8Uw7o X-Received: by 2002:a63:7e1b:: with SMTP id z27-v6mr6607028pgc.65.1529200858770; Sat, 16 Jun 2018 19:00:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529200858; cv=none; d=google.com; s=arc-20160816; b=OEfqPPYMUM2nsHree8jsBMdFgmscYpXmOzrV4IduBHLQSjjoUrLWYzTkPcF1KGGD4m hv/OpL88kWlv/JbW0q1C5PQIQOpKs6gwrO2KI+xIF+Jxfnj4M3QBQH8y2CAQqKRvextC mFdgoertr5s2sBMfGNJqlCpLNC7uw3zYlVOvwR7hfT5MGDsaoEyPAneIE5xNrnGLO8TL IoKVN5hE8k1To6wor9IOcYZa1BARc7i72hDV0Vhhjn91b2aCoEK1XeNzLCrA15HVXZfy D9AbCIvelb/rHvRgilBUpa5mUjqqndvlwjGh5/HcG0z5gV8wtY511UYODYBBQ8N1cIkW iblg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=nEu/iSteNkAMtQpngBIONZNFiPmqdnQM7MosSEs/KsA=; b=0++WTHKaacaCwozwpEq0jw66t3EGKfyqtGXX0KwPIsBKXYIR/ObA7f1xKczZuk9Iv6 0sS0dCfjI5qxCFdCMIX9h0vL8FlOY0HI6e+jKChU6aSUyhRZWSOAXDvprhU87Od5tAJh jfwpv11pC3j+1mmSNcKK+zBS3EOecOkJSDwrqs3OC6JGEY+cSE10rjmI09A80iK6+Vo6 npOrfbrfQgfURrx60ArF8wrWV9eL21XiJ/LsbM3G5dj6v9OT729zAq7T2Ebzcy4qYVu0 HhWEDEqbc6rkDgr0a92rpAuJv9uJU73f2mFjR4XYBWkEMtXCs+tMfiJZjvFkkwscQ00P gBcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=kODSpXqa; spf=pass (google.com: best guess record for domain of willy@infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=willy@infradead.org Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id a7-v6si9451593pgv.360.2018.06.16.19.00.58 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 16 Jun 2018 19:00:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of willy@infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=kODSpXqa; spf=pass (google.com: best guess record for domain of willy@infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=willy@infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=nEu/iSteNkAMtQpngBIONZNFiPmqdnQM7MosSEs/KsA=; b=kODSpXqayiCTcEDvEYp/du24p sHIETX/XLFNJ2x1FtUmzvI+5AhfyICUN1P1iIrKcZZq4YS2bTVrtulRcevE++kOxNSgE9liMK3r6y B9W1fyERkDG3EG57hLYrOLC9W9mM/T7XuEPCz5XHayZU28oZAyZy7s45OyHux0Y21ru2/DpO/Jhnr g88/XZN1qYipFNG/U74ZdF/zfrUkcn4xC3+So1vXqrCuTT1sbApIxqGcXNvJG+Ue1lPgZGfVkkbGy kWfqitaQrO3YxVqhDCbghShp5VcdY/qCIG3Cux4b4pP7GOw9uWh5m4qlogtT4/tkCou/hCmpF0b8C J05KHhR/Q==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1fUMzu-0001Ff-PB; Sun, 17 Jun 2018 02:00:54 +0000 From: Matthew Wilcox To: linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Matthew Wilcox , Jan Kara , Jeff Layton , Lukas Czerner , Ross Zwisler , Christoph Hellwig , Goldwyn Rodrigues , Nicholas Piggin , Ryusuke Konishi , linux-nilfs@vger.kernel.org, Jaegeuk Kim , Chao Yu , linux-f2fs-devel@lists.sourceforge.net Subject: [PATCH v14 02/74] radix tree test suite: Enable ubsan Date: Sat, 16 Jun 2018 18:59:40 -0700 Message-Id: <20180617020052.4759-3-willy@infradead.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180617020052.4759-1-willy@infradead.org> References: <20180617020052.4759-1-willy@infradead.org> 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 Add support for the undefined behaviour sanitizer and fix the bugs that ubsan pointed out. Nothing major, and all in the test suite, not the code. Signed-off-by: Matthew Wilcox --- tools/testing/radix-tree/Makefile | 5 +++-- tools/testing/radix-tree/main.c | 20 +++++++++++--------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/tools/testing/radix-tree/Makefile b/tools/testing/radix-tree/Makefile index db66f8a0d4be..da030a65d6d6 100644 --- a/tools/testing/radix-tree/Makefile +++ b/tools/testing/radix-tree/Makefile @@ -1,7 +1,8 @@ # SPDX-License-Identifier: GPL-2.0 -CFLAGS += -I. -I../../include -g -O2 -Wall -D_LGPL_SOURCE -fsanitize=address -LDFLAGS += -fsanitize=address +CFLAGS += -I. -I../../include -g -Og -Wall -D_LGPL_SOURCE -fsanitize=address \ + -fsanitize=undefined +LDFLAGS += -fsanitize=address -fsanitize=undefined LDLIBS+= -lpthread -lurcu TARGETS = main idr-test multiorder CORE_OFILES := radix-tree.o idr.o linux.o test.o find_bit.o diff --git a/tools/testing/radix-tree/main.c b/tools/testing/radix-tree/main.c index 257f3f8aacaa..584a8732f5ce 100644 --- a/tools/testing/radix-tree/main.c +++ b/tools/testing/radix-tree/main.c @@ -27,20 +27,22 @@ void __gang_check(unsigned long middle, long down, long up, int chunk, int hop) item_check_present(&tree, middle + idx); item_check_absent(&tree, middle + up); - item_gang_check_present(&tree, middle - down, - up + down, chunk, hop); - item_full_scan(&tree, middle - down, down + up, chunk); + if (chunk > 0) { + item_gang_check_present(&tree, middle - down, up + down, + chunk, hop); + item_full_scan(&tree, middle - down, down + up, chunk); + } item_kill_tree(&tree); } void gang_check(void) { - __gang_check(1 << 30, 128, 128, 35, 2); - __gang_check(1 << 31, 128, 128, 32, 32); - __gang_check(1 << 31, 128, 128, 32, 100); - __gang_check(1 << 31, 128, 128, 17, 7); - __gang_check(0xffff0000, 0, 65536, 17, 7); - __gang_check(0xfffffffe, 1, 1, 17, 7); + __gang_check(1UL << 30, 128, 128, 35, 2); + __gang_check(1UL << 31, 128, 128, 32, 32); + __gang_check(1UL << 31, 128, 128, 32, 100); + __gang_check(1UL << 31, 128, 128, 17, 7); + __gang_check(0xffff0000UL, 0, 65536, 17, 7); + __gang_check(0xfffffffeUL, 1, 1, 17, 7); } void __big_gang_check(void)