From patchwork Wed Feb 19 04:54:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Chancellor X-Patchwork-Id: 11390353 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DAF3E924 for ; Wed, 19 Feb 2020 04:55:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BBD0324656 for ; Wed, 19 Feb 2020 04:55:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="GxU8H+8w" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726663AbgBSEyd (ORCPT ); Tue, 18 Feb 2020 23:54:33 -0500 Received: from mail-oi1-f196.google.com ([209.85.167.196]:34932 "EHLO mail-oi1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726623AbgBSEyd (ORCPT ); Tue, 18 Feb 2020 23:54:33 -0500 Received: by mail-oi1-f196.google.com with SMTP id b18so22608360oie.2; Tue, 18 Feb 2020 20:54:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=z4GEXAYyqQWsp025ogzeKnxOXkjpBM0jeh4Jkb1AQ/E=; b=GxU8H+8wHFYPadW4JaajZHSEVBcXNLGzyU3EcBZXx+nG/SCQ/ASmuoJLfPCPUeuTcU FPKoRZq2suxke3wLsTkQ3/gIM1UWeWVU52/tJzPsh7F9zxB1xTyPTqbDXA2XcyCzn8kA iWG/YrzUa7yE/uj8JF+ADOrARv+qXt5jGgHTl3dGWyQcvrNsChBzUM6v8hKbMjzOjbne Dv7HJtHNa1r3sg4kQxML6Nc9dqgwX2cEoYxS/8LynvMCvXhgd/YzZn9ZWcXiUNKliTpN gvs8opTGiEwt6oK3ylCI00rjpTlVbwmdaK08ckbydc41KM39Ff9Rfz2SBcq1CUbJye9R M1NQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=z4GEXAYyqQWsp025ogzeKnxOXkjpBM0jeh4Jkb1AQ/E=; b=YFJN4/G02fdhn8rp+qetJjO4Oq/sf4ht2kjX8GBFJPUt5ZwqmG1m/fQYU4c5o7S9nN Cz3qjC+75KdISfjI8JWwzxI98SNmODfFsnF9qnqBMnEYUftMTjg3GWbNQOiZO2xwibMD mz19vnrnpN2OjpsB3Dmq0r8xQOk8d73j8xS2JPZ29mI9RxxJ0cifPgG+cXzJriCCIlxO ctG/PeOS4m3A8pNzOEe7/LZlhDtWbXLhzuNSGI7y6Fmwab7XKJhhIIEjJaN92XwQvhCG M81BYaj7d2YgecelH9lH1mE4KL1wb3OeRA+rj8IZOoRX+OxcV98guokFQgElq2Yo0G37 O8PA== X-Gm-Message-State: APjAAAWspdyzS2Yh/8DEinxL3Yh25ytexeXR+TqjmCnnbYuFLtMJsunw U7FtGoyQ4rsBHUO0NpoEOhU= X-Google-Smtp-Source: APXvYqzPqnhDSnUTxbnbVTbSbPmWK7BxoBMVOIdmKFVTG3pZ9TJDv5U6RijdtiI3Af1f4g1Jjlyyqw== X-Received: by 2002:aca:c7ca:: with SMTP id x193mr3514163oif.70.1582088072470; Tue, 18 Feb 2020 20:54:32 -0800 (PST) Received: from localhost.localdomain ([2604:1380:4111:8b00::1]) by smtp.gmail.com with ESMTPSA id c7sm288894otn.81.2020.02.18.20.54.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Feb 2020 20:54:32 -0800 (PST) From: Nathan Chancellor To: Masahiro Yamada , Michal Marek , Arnd Bergmann , Steven Rostedt , Ingo Molnar , Jason Baron , Catalin Marinas , Andrew Morton Cc: linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, clang-built-linux@googlegroups.com, Nathan Chancellor Subject: [PATCH 1/6] asm/sections: Add COMPARE_SECTIONS macro Date: Tue, 18 Feb 2020 21:54:18 -0700 Message-Id: <20200219045423.54190-2-natechancellor@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200219045423.54190-1-natechancellor@gmail.com> References: <20200219045423.54190-1-natechancellor@gmail.com> MIME-Version: 1.0 X-Patchwork-Bot: notify Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org When building with clang's -Wtautological-compare, there are a few warnings around the comparison of section boundaries, which are linker defined symbols and just contain an address. Clang says that these comparisons always evaluate to a constant because it thinks they are regular arrays. This result is expected and reasonable since we just care about its boolean value. The kernel does this to figure out how exactly it was laid out during link time so that it can make certain run time decisions without hard coding them via preprocessor macros. These comparisons always evaluate the way that the kernel wants (done by comparing a Clang built kernel to a GCC built kernel). As a result, this warning should be silenced in these particular instances so that -Wtautological-compare can be enabled for the kernel globally since it brings several useful warnings within its group. In other words, by disabling -Wtautological-compare, the kernel misses out on several useful subwarnings that are found with existing static checkers; catching things with the compiler at build time will make it easier to catch issues, especially as clang starts to be integrated into CI systems. The warnings can be silenced by casting the linked defined symbols to unsigned long (normally uintptr_t but the kernel typedef's uintptr_t to unsigned long and some kernel developers prefer unsigned long) to make them purely numeric comparisons, which will be converted to a boolean without any warning from Clang. The casting is done within a macro so that it can be documented why this casting happens, rather than sprinkling random casts in the few places that this happens within the kernel. Link: https://github.com/ClangBuiltLinux/linux/issues/765 Signed-off-by: Nathan Chancellor --- include/asm-generic/sections.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/include/asm-generic/sections.h b/include/asm-generic/sections.h index d1779d442aa5..e1f3095a50c1 100644 --- a/include/asm-generic/sections.h +++ b/include/asm-generic/sections.h @@ -169,4 +169,11 @@ static inline bool is_kernel_rodata(unsigned long addr) addr < (unsigned long)__end_rodata; } +/* + * Comparing section boundaries trips clang's -Wtautological-compare + * This silences that warning by making the comparisons purely numeric + */ +#define COMPARE_SECTIONS(section_one, op, section_two) \ + ((unsigned long)(section_one) op (unsigned long)(section_two)) + #endif /* _ASM_GENERIC_SECTIONS_H_ */ From patchwork Wed Feb 19 04:54:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Chancellor X-Patchwork-Id: 11390351 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 303DC924 for ; Wed, 19 Feb 2020 04:55:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 114BB24676 for ; Wed, 19 Feb 2020 04:55:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="oJcPu03T" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726707AbgBSEyf (ORCPT ); Tue, 18 Feb 2020 23:54:35 -0500 Received: from mail-ot1-f66.google.com ([209.85.210.66]:41635 "EHLO mail-ot1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726496AbgBSEye (ORCPT ); Tue, 18 Feb 2020 23:54:34 -0500 Received: by mail-ot1-f66.google.com with SMTP id r27so21881225otc.8; Tue, 18 Feb 2020 20:54:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gB9HKBd9NE/ic7aLq2Zv7PAn+vedvEO6GTMd/7/cXT8=; b=oJcPu03TiqY6QgcSJwosaNcUNgizcMJBajDzA1jPGSOgixPcHSmfe23+opqORZk+vq 5uEhlpBEZOCyGWUePBMoNwLLLl0IWMPZe+VWpXNaOBx9cZ2zeUJPWQtY0dTiHewXAffD 4ifNb7wpeVSJ/pu6EVwX48D+XsoqpU25UVo48MKzoIANF1gwZwNgeaclQE8DvLhARL6C vHBM4LOnGhOmLrkDNGQWEpeKwKFqTzI1o0YnVyyE2morwLQjSjNMJuiLyIbB5rfpRg8o RWSsvGScSkalMGARf0Bb9ufIkNFTU4mFhypytRC2FcYl+1mfsPuZe3rwAIyy4dICfd5R Yt5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gB9HKBd9NE/ic7aLq2Zv7PAn+vedvEO6GTMd/7/cXT8=; b=sX/RdFUe0cvKQ0y3DBeLoXTwE6BMnaK8xx8x029edWzhQZCh3muuWgfJqQDgKiB/8i gHQXSgcxuxkfk0lwU/P4jcoAVoGWq0H7ojCexzAvjsD8cyGy7r8zyXUjjHdm9dCJOibl VymFKNGm9emGzDXNQb+nMc0gCGy3hmpWXeCqrrSN+kK4WMAcXuAGBfEcxSF82plru+LA W9GEz+kqUC5vkx9Y/xQzAD61m9sTibJJI9p0pAqLAz2M4q6Mwf1uVfIPuYgrbmoXsn8G ePARjrNxgF9q5/G0v4d/nI4C40KRnPWxxQt1BjIR+KYUJlMgMZEmz0wQxNcTQ1CIXV9E 1VAA== X-Gm-Message-State: APjAAAXmuhaGNCLtD+JhR0tnFrDQE9SYcvFrsHZdBQ5Me6aPmK4eEnwW jGpZXYdJSt4jsmqlcEm35rA= X-Google-Smtp-Source: APXvYqwdFwp4qn7ny2TvCGnaQaQjscbRAz+omD8OlFFTCu1L1VgwqztyBfFMZgIeIPZS92nhreHqNA== X-Received: by 2002:a9d:6b12:: with SMTP id g18mr17801067otp.211.1582088073480; Tue, 18 Feb 2020 20:54:33 -0800 (PST) Received: from localhost.localdomain ([2604:1380:4111:8b00::1]) by smtp.gmail.com with ESMTPSA id c7sm288894otn.81.2020.02.18.20.54.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Feb 2020 20:54:32 -0800 (PST) From: Nathan Chancellor To: Masahiro Yamada , Michal Marek , Arnd Bergmann , Steven Rostedt , Ingo Molnar , Jason Baron , Catalin Marinas , Andrew Morton Cc: linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, clang-built-linux@googlegroups.com, Nathan Chancellor Subject: [PATCH 2/6] kernel/extable: Wrap section comparison in sort_main_extable with COMPARE_SECTIONS Date: Tue, 18 Feb 2020 21:54:19 -0700 Message-Id: <20200219045423.54190-3-natechancellor@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200219045423.54190-1-natechancellor@gmail.com> References: <20200219045423.54190-1-natechancellor@gmail.com> MIME-Version: 1.0 X-Patchwork-Bot: notify Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org Clang warns: ../kernel/extable.c:37:52: warning: array comparison always evaluates to a constant [-Wtautological-compare] if (main_extable_sort_needed && __stop___ex_table > __start___ex_table) { ^ 1 warning generated. These are not true arrays, they are linker defined symbols, which are just addresses so there is not a real issue here. Use the COMPARE_SECTIONS macro to silence this warning by casting the linker defined symbols to unsigned long, which keeps the logic the same. Link: https://github.com/ClangBuiltLinux/linux/issues/765 Signed-off-by: Nathan Chancellor --- kernel/extable.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kernel/extable.c b/kernel/extable.c index a0024f27d3a1..17bf4ccb9de9 100644 --- a/kernel/extable.c +++ b/kernel/extable.c @@ -34,7 +34,8 @@ u32 __initdata __visible main_extable_sort_needed = 1; /* Sort the kernel's built-in exception table */ void __init sort_main_extable(void) { - if (main_extable_sort_needed && __stop___ex_table > __start___ex_table) { + if (main_extable_sort_needed && + COMPARE_SECTIONS(__stop___ex_table, >, __start___ex_table)) { pr_notice("Sorting __ex_table...\n"); sort_extable(__start___ex_table, __stop___ex_table); } From patchwork Wed Feb 19 04:54:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Chancellor X-Patchwork-Id: 11390347 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A342E17F0 for ; Wed, 19 Feb 2020 04:54:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 83A7924658 for ; Wed, 19 Feb 2020 04:54:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="RlTQIa8C" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726734AbgBSEyg (ORCPT ); Tue, 18 Feb 2020 23:54:36 -0500 Received: from mail-oi1-f193.google.com ([209.85.167.193]:40622 "EHLO mail-oi1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726623AbgBSEyf (ORCPT ); Tue, 18 Feb 2020 23:54:35 -0500 Received: by mail-oi1-f193.google.com with SMTP id a142so22569048oii.7; Tue, 18 Feb 2020 20:54:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Dr2Q+aHg/1SGjzpWBsBNv11ATwozDGCBBkaKKg29VLU=; b=RlTQIa8CRCM+VNzdVRfUcZhF+5zjAHPs4z0EywqhlgDJhQIBms6nhmImjyHTTHYkOy kAE1qCHWRhwFAjVqLvaXZJa49nISb8dLeexOQVcMXPsAchxmy08bxmlmomC0ljC4G6r/ TPAs3CCUKPBkIrP/fhQdDQthulzH5Mx98wdmPnKA4kQLIIZVOm1iycVFu/zwQzT6lvAs IAELIMXwPbuzc3ConrlHpGVxcz4GPCA6jwhoQCgJFAH91pN7I24IxHQJoVQwmxq+q/US yFqU1TwG+sb6fsmvXFmjg9uYEDKwyxy2qReN/DutUyQQASjz7GWVWs8oeR5tslTVZTNO Bd0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Dr2Q+aHg/1SGjzpWBsBNv11ATwozDGCBBkaKKg29VLU=; b=CnNwVYxo05cDLWodHhpy6sXVZGrzR7ng5HE4yI2+0RkFCk0vbU7SV7tIcGt8vz1RjF J8TRGaYDTf/ZWCw5X0Dy/zgsKOWsZCSt9MoBGNOSGgaXcr3+FEKW14ylpZi5So0ZCp1r dpXF11Me7+WmKvqrIzH5LZbcebkhjbmOlQhfoUzX/v5u0D5zI73tzZ+6f3m0cPyaG9q8 4WQ3hdyPJG9t+TrV5N4vp30FS3Y5kUpZ1t7FKlqZt3wNDT2/6FvsWNPbmiWEvgYm0OAk 6mo3RfIYCiUi3oaGs9TIGwyA9tDWVW3OGegkL0oEyYNl3jXAOAVB+gj55jR4+AFaSFlA /4Ww== X-Gm-Message-State: APjAAAUYhMnJprMKBo3NHJzCQ4/GieKIDvm2FkQ+WYHRybPE2v8R7gDF gMZrjyynHJbfMT04YNy/WFI= X-Google-Smtp-Source: APXvYqxyb3BnXAjNQrjcn8HqOmkV+kjEbAKY9iDmYxHQnfG5ebZsrdug8IdEe5BqVTLiXeR2InjgJQ== X-Received: by 2002:aca:5dc3:: with SMTP id r186mr3577268oib.137.1582088074161; Tue, 18 Feb 2020 20:54:34 -0800 (PST) Received: from localhost.localdomain ([2604:1380:4111:8b00::1]) by smtp.gmail.com with ESMTPSA id c7sm288894otn.81.2020.02.18.20.54.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Feb 2020 20:54:33 -0800 (PST) From: Nathan Chancellor To: Masahiro Yamada , Michal Marek , Arnd Bergmann , Steven Rostedt , Ingo Molnar , Jason Baron , Catalin Marinas , Andrew Morton Cc: linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, clang-built-linux@googlegroups.com, Nathan Chancellor Subject: [PATCH 3/6] tracing: Wrap section comparison in tracer_alloc_buffers with COMPARE_SECTIONS Date: Tue, 18 Feb 2020 21:54:20 -0700 Message-Id: <20200219045423.54190-4-natechancellor@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200219045423.54190-1-natechancellor@gmail.com> References: <20200219045423.54190-1-natechancellor@gmail.com> MIME-Version: 1.0 X-Patchwork-Bot: notify Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org Clang warns: ../kernel/trace/trace.c:9335:33: warning: array comparison always evaluates to true [-Wtautological-compare] if (__stop___trace_bprintk_fmt != __start___trace_bprintk_fmt) ^ 1 warning generated. These are not true arrays, they are linker defined symbols, which are just addresses so there is not a real issue here. Use the COMPARE_SECTIONS macro to silence this warning by casting the linker defined symbols to unsigned long, which keeps the logic the same. Link: https://github.com/ClangBuiltLinux/linux/issues/765 Signed-off-by: Nathan Chancellor --- kernel/trace/trace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index c797a15a1fc7..e1f3b16e457b 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c @@ -9332,7 +9332,7 @@ __init static int tracer_alloc_buffers(void) goto out_free_buffer_mask; /* Only allocate trace_printk buffers if a trace_printk exists */ - if (__stop___trace_bprintk_fmt != __start___trace_bprintk_fmt) + if (COMPARE_SECTIONS(__stop___trace_bprintk_fmt, !=, __start___trace_bprintk_fmt)) /* Must be called before global_trace.buffer is allocated */ trace_printk_init_buffers(); From patchwork Wed Feb 19 04:54:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Chancellor X-Patchwork-Id: 11390345 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 36490159A for ; Wed, 19 Feb 2020 04:54:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1769424658 for ; Wed, 19 Feb 2020 04:54:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="CGR/0y06" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726754AbgBSEyh (ORCPT ); Tue, 18 Feb 2020 23:54:37 -0500 Received: from mail-ot1-f66.google.com ([209.85.210.66]:46808 "EHLO mail-ot1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726715AbgBSEyg (ORCPT ); Tue, 18 Feb 2020 23:54:36 -0500 Received: by mail-ot1-f66.google.com with SMTP id g64so21892975otb.13; Tue, 18 Feb 2020 20:54:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=5UFOi8jLMJhZKfbS1bLXcN2MTOzPVzspy8Ufb+K/+9A=; b=CGR/0y06bDux3uipIKmL2A6gq/Cjwnfz6TpotKAct40JBSC1dCgyK/xpIMrUuQqODG ndabVlZXu3nu5sDRXd5T6gc+0Z5fnGquP6EpnNzE86kWuGTBiNeWK9EQAry7s3uaNTb6 eGn2yiX29eXa/P82eFd5E4QAdhju0gshmPP1AuAgAxgIEllQg0iQsrb+ECFDI2+AvB9r +fQurI2f1KQsm6vtGkq+TCmq4jlPB/gWa1h33C20pXb5fZ5KIAZ4UcmMoGzUaiHRI5mH kog8lhdtN1kfcA5LAqLn0c6uFsltFxkqPIXvqql6Pzi81xN5aIMqpQ4LObP47x/z4Yhq yUNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=5UFOi8jLMJhZKfbS1bLXcN2MTOzPVzspy8Ufb+K/+9A=; b=I5lWT6yeXZnoJWyqH+18K+FMJI3J4vUtIX+F6gplLa8tw/c2dvmCGO1VMz/cRu1nTn 7A5cRIeivj0UyvMmptDb0YrqYbJhjurFcmamhTlppTbqWU8a1H2Q9X6lK0bxt/mqBHQH kB/ALpZFDqTWWUwwjr4bgwYs/hhOLS1Hq30r1bbI86Ou/UC8ZMuBjVrmCyR6qXrv/z/f prS5EWc4RWVEyH6SEUaFNwsF0skWXs6y1oTf3XbIX6KTUXzQ2fNBP6h8xT9z32RRfA75 yLJtdrIzqSzQnEX3v6cz4Ke/qWY+m92hQr0zF8NbPldLwShP8xAbvztyBOmCQMcs3RQO 9BuQ== X-Gm-Message-State: APjAAAW4KuUPEk19NYNPi5QjTJ70GWSGDUDtyQYDu3eblVBHv9sohit4 L++8Vy31Ga1+l9vxGnD1+6M= X-Google-Smtp-Source: APXvYqyYvjiYUbVKqo1foePiJ1LRz3yob4g25LDX4h9uBovWKx7QdkcX8t6eDUmuVpPdUDin0haoFw== X-Received: by 2002:a9d:7dc9:: with SMTP id k9mr18133478otn.117.1582088075110; Tue, 18 Feb 2020 20:54:35 -0800 (PST) Received: from localhost.localdomain ([2604:1380:4111:8b00::1]) by smtp.gmail.com with ESMTPSA id c7sm288894otn.81.2020.02.18.20.54.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Feb 2020 20:54:34 -0800 (PST) From: Nathan Chancellor To: Masahiro Yamada , Michal Marek , Arnd Bergmann , Steven Rostedt , Ingo Molnar , Jason Baron , Catalin Marinas , Andrew Morton Cc: linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, clang-built-linux@googlegroups.com, Nathan Chancellor Subject: [PATCH 4/6] dynamic_debug: Wrap section comparison in dynamic_debug_init with COMPARE_SECTIONS Date: Tue, 18 Feb 2020 21:54:21 -0700 Message-Id: <20200219045423.54190-5-natechancellor@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200219045423.54190-1-natechancellor@gmail.com> References: <20200219045423.54190-1-natechancellor@gmail.com> MIME-Version: 1.0 X-Patchwork-Bot: notify Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org Clang warns: ../lib/dynamic_debug.c:1016:24: warning: array comparison always evaluates to false [-Wtautological-compare] if (__start___verbose == __stop___verbose) { ^ 1 warning generated. These are not true arrays, they are linker defined symbols, which are just addresses so there is not a real issue here. Use the COMPARE_SECTIONS macro to silence this warning by casting the linker defined symbols to unsigned long, which keeps the logic the same. Link: https://github.com/ClangBuiltLinux/linux/issues/765 Signed-off-by: Nathan Chancellor --- lib/dynamic_debug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index aae17d9522e5..c7350aa6e853 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -1031,7 +1031,7 @@ static int __init dynamic_debug_init(void) int n = 0, entries = 0, modct = 0; int verbose_bytes = 0; - if (__start___verbose == __stop___verbose) { + if (COMPARE_SECTIONS(__start___verbose, ==, __stop___verbose)) { pr_warn("_ddebug table is empty in a CONFIG_DYNAMIC_DEBUG build\n"); return 1; } From patchwork Wed Feb 19 04:54:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Chancellor X-Patchwork-Id: 11390349 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 060D6924 for ; Wed, 19 Feb 2020 04:54:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DB75024676 for ; Wed, 19 Feb 2020 04:54:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="J/JOa0IR" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726548AbgBSEyu (ORCPT ); Tue, 18 Feb 2020 23:54:50 -0500 Received: from mail-ot1-f68.google.com ([209.85.210.68]:40216 "EHLO mail-ot1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726739AbgBSEyh (ORCPT ); Tue, 18 Feb 2020 23:54:37 -0500 Received: by mail-ot1-f68.google.com with SMTP id i6so21922314otr.7; Tue, 18 Feb 2020 20:54:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=jXMSq1G5rPTXUEP5geAUCtTmXJBdNGAIZfUMzXa3xpk=; b=J/JOa0IRUSQzS/wfLNZGUESDgz1LVTCC8zLL4GgLJN3TkqqBKqbwTtKzVV+LKQA/ow Ctahh1xRv+Cjvv8ps3OzOLyz0wsgaXJYVIUktvu7gxbtjoVSvKOjLPBf2kHlscZCiHiN rabnjLDU1PUlEMJAtn6k1Zde4XJg6WcwaOUl2cBKDUlCkAiaN0aRXU7B1+fST7KgxUc8 plxxVegSLtHSF2Kpo7GnyPEjvBEqw4jusa3DIb+rb9MEpwvSQsLaH834lRk7M/UNPdnw AMNyVfRD1iwflZr8McSRr6QzaZzvWMNXySOrrLThSzklcMr35jGETEW9goqvDy0a1lYR 8tPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=jXMSq1G5rPTXUEP5geAUCtTmXJBdNGAIZfUMzXa3xpk=; b=mg1jVHMwWSwI1h1zQn0NVKhhHwwfxavdgHnPkFhyG0lD4w6ykpWfBT5jbwLvn77x98 ESrY4a5YHASP9jH8dtRytwKaFP2aS7wQ17WPskTuJlN4wd58HnapuTVOVDMlPQ4eljk0 fjwaCrh1iPd0aANqJ8g86pfMEGvirbjWKLcmPrczG4Xm2uKFdiIEChEeJn85V67fq57w 2DYTke4t331QgmOzr4wGf1T/VZh92HHZSI19vzuqfTAbkTUX/cs1+t0nvG97T3mQ2QDl fbclDRy6rg31iGhx05/6MSv2Xzkwog922OAb/ER1EFQua5o1sukxSZ0cqJaYhVAcOpqi zVUQ== X-Gm-Message-State: APjAAAUfiYAQprj2lQA0hCBB/Zp4AAXhM07PZNDR2VDtkLLSfoYUeI0F ryZKI6ukWcd7GF9aKKE264E= X-Google-Smtp-Source: APXvYqzGvAZO0x9jw5WmNLprzgTxW6R8oyixD2CIDl8AUW+oyej/NaXt3g2Xbd0NMuq30pnEIYLxNQ== X-Received: by 2002:a9d:6415:: with SMTP id h21mr19176451otl.152.1582088076125; Tue, 18 Feb 2020 20:54:36 -0800 (PST) Received: from localhost.localdomain ([2604:1380:4111:8b00::1]) by smtp.gmail.com with ESMTPSA id c7sm288894otn.81.2020.02.18.20.54.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Feb 2020 20:54:35 -0800 (PST) From: Nathan Chancellor To: Masahiro Yamada , Michal Marek , Arnd Bergmann , Steven Rostedt , Ingo Molnar , Jason Baron , Catalin Marinas , Andrew Morton Cc: linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, clang-built-linux@googlegroups.com, Nathan Chancellor Subject: [PATCH 5/6] mm: kmemleak: Wrap section comparison in kmemleak_init with COMPARE_SECTIONS Date: Tue, 18 Feb 2020 21:54:22 -0700 Message-Id: <20200219045423.54190-6-natechancellor@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200219045423.54190-1-natechancellor@gmail.com> References: <20200219045423.54190-1-natechancellor@gmail.com> MIME-Version: 1.0 X-Patchwork-Bot: notify Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org Clang warns: ../mm/kmemleak.c:1950:28: warning: array comparison always evaluates to a constant [-Wtautological-compare] if (__start_ro_after_init < _sdata || __end_ro_after_init > _edata) ^ ../mm/kmemleak.c:1950:60: warning: array comparison always evaluates to a constant [-Wtautological-compare] if (__start_ro_after_init < _sdata || __end_ro_after_init > _edata) ^ 2 warnings generated. These are not true arrays, they are linker defined symbols, which are just addresses so there is not a real issue here. Use the COMPARE_SECTIONS macro to silence this warning by casting the linker defined symbols to unsigned long, which keeps the logic the same. Link: https://github.com/ClangBuiltLinux/linux/issues/765 Signed-off-by: Nathan Chancellor --- mm/kmemleak.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mm/kmemleak.c b/mm/kmemleak.c index aa6832432d6a..e27655526ba7 100644 --- a/mm/kmemleak.c +++ b/mm/kmemleak.c @@ -1952,7 +1952,8 @@ void __init kmemleak_init(void) create_object((unsigned long)__bss_start, __bss_stop - __bss_start, KMEMLEAK_GREY, GFP_ATOMIC); /* only register .data..ro_after_init if not within .data */ - if (__start_ro_after_init < _sdata || __end_ro_after_init > _edata) + if (COMPARE_SECTIONS(__start_ro_after_init, <, _sdata) || + COMPARE_SECTIONS(__end_ro_after_init, >, _edata)) create_object((unsigned long)__start_ro_after_init, __end_ro_after_init - __start_ro_after_init, KMEMLEAK_GREY, GFP_ATOMIC); From patchwork Wed Feb 19 04:54:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Chancellor X-Patchwork-Id: 11390343 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0F76E924 for ; Wed, 19 Feb 2020 04:54:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E402924658 for ; Wed, 19 Feb 2020 04:54:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="WBwXIcH5" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726766AbgBSEyj (ORCPT ); Tue, 18 Feb 2020 23:54:39 -0500 Received: from mail-ot1-f68.google.com ([209.85.210.68]:34149 "EHLO mail-ot1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726750AbgBSEyh (ORCPT ); Tue, 18 Feb 2020 23:54:37 -0500 Received: by mail-ot1-f68.google.com with SMTP id j16so21947187otl.1; Tue, 18 Feb 2020 20:54:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Oh9QWb6pZZ5g69dU4FZ2txutGr0B2CSvIaPTiYXdnPo=; b=WBwXIcH52wj5UStzSlDaw2Ph8pzj/CYP3JRSbf54GZh79pza3d3RsxczDsukrXWSZ7 86khT4brEkZbiwPESK+rtMahwlr7gE+9fQ0NRJakjryJkgDvh9ACjcNovCc0J9Sy5zll 88LmmWVIvK2n273H7MJxpeDiBFbG2x5vk5wpwRXdCTotbpecqAQ1qdXfoQlb9uRU2yC6 AvaBlQeWFdJnomzIM4hTbQfiEfCtrzQIMaRLgjQ8s6iN9JZCPEhU2N1slMVrr1UU1AB5 El1e5Hnaz3m5KCaZqWo0pgU+ojOgoCdxbASQRLncZppeIXyvOm7iU+Zj2f6dMYh6cEHr 9hIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Oh9QWb6pZZ5g69dU4FZ2txutGr0B2CSvIaPTiYXdnPo=; b=eEr7zdgp6grefX5RYr/3Cui9Kl+NUVu3sZWaKBycnKi8Rbwr6Q+Efghw749+QO/NqJ KjvY18nlFgP5TmLM05+e2VPv+8l9OwNH03QeZa1frxuTgXKureVewbSHUMPy2NL6mxwz C5yhHDHc+vpVNUqItf56O0gJWmuj0cQTuyQ5R4nc++OszPgq3QnWFB28oWfLHSEWSx7E VXbhYjaJdOviA2gzg3REpWHxFPDN6e6gyF6U4LQbKZ2ECgRDhiYA9+z31IufOf4miljW U7xyixRkerVWtanCBtjL7+jggyo19ULYHGZnqTBrOwGXp/vZejE/D1Q+vUVls+XRu6rS wNSQ== X-Gm-Message-State: APjAAAUPzO6wXMt4JF17kaA/7ieWJZHPC5pfddLM6wXa9yenz1mGZplb K7Te3cOyx6v/L1dK06aYgxs= X-Google-Smtp-Source: APXvYqxJRG2OQXc05asgj7HXthiAW2UIejHZq7541ZiIpdLqpMSEi/rSorSHXLJ0a/aaTltGwjj13Q== X-Received: by 2002:a05:6830:1d91:: with SMTP id y17mr17502659oti.276.1582088077039; Tue, 18 Feb 2020 20:54:37 -0800 (PST) Received: from localhost.localdomain ([2604:1380:4111:8b00::1]) by smtp.gmail.com with ESMTPSA id c7sm288894otn.81.2020.02.18.20.54.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Feb 2020 20:54:36 -0800 (PST) From: Nathan Chancellor To: Masahiro Yamada , Michal Marek , Arnd Bergmann , Steven Rostedt , Ingo Molnar , Jason Baron , Catalin Marinas , Andrew Morton Cc: linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, clang-built-linux@googlegroups.com, Nathan Chancellor Subject: [PATCH 6/6] kbuild: Enable -Wtautological-compare Date: Tue, 18 Feb 2020 21:54:23 -0700 Message-Id: <20200219045423.54190-7-natechancellor@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200219045423.54190-1-natechancellor@gmail.com> References: <20200219045423.54190-1-natechancellor@gmail.com> MIME-Version: 1.0 X-Patchwork-Bot: notify Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org Currently, we disable -Wtautological-compare, which in turn disables a bunch of more specific tautological comparison warnings that are useful for the kernel (see clang's documentation below). Now that all of the major/noisy warnings have been fixed, enable -Wtautological-compare so that more issues can be caught at build time. -Wtautological-constant-out-of-range-compare is kept disabled because there are places in the kernel where a constant or variable size can change based on the kernel configuration; these are not fixed in a clean/concise way and they are almost always harmless so this one subwarning is kept disabled. Link: https://github.com/ClangBuiltLinux/linux/issues/488 Link: http://releases.llvm.org/9.0.0/tools/clang/docs/DiagnosticsReference.html#wtautological-compare Signed-off-by: Nathan Chancellor --- Makefile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Makefile b/Makefile index b954c304c479..99080c57a1cb 100644 --- a/Makefile +++ b/Makefile @@ -742,8 +742,7 @@ ifdef CONFIG_CC_IS_CLANG KBUILD_CPPFLAGS += -Qunused-arguments KBUILD_CFLAGS += -Wno-format-invalid-specifier KBUILD_CFLAGS += -Wno-gnu -# Quiet clang warning: comparison of unsigned expression < 0 is always false -KBUILD_CFLAGS += -Wno-tautological-compare +KBUILD_CFLAGS += -Wno-tautological-constant-out-of-range-compare # CLANG uses a _MergedGlobals as optimization, but this breaks modpost, as the # source of a reference will be _MergedGlobals and not on of the whitelisted names. # See modpost pattern 2