From patchwork Mon Jun 11 16:05:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Chancellor X-Patchwork-Id: 138256 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp4234549lji; Mon, 11 Jun 2018 09:06:03 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJzfGvMvqp3jXb0hs7z/xpZhBJ7UNmAJjrSXgvS4CB5aaXWx6bVvaOgTK6yhvw0se76Zje6 X-Received: by 2002:a62:6f86:: with SMTP id k128-v6mr18320568pfc.150.1528733162815; Mon, 11 Jun 2018 09:06:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528733162; cv=none; d=google.com; s=arc-20160816; b=PBXqJxesTh2e7w9KBlUX+pJUJtuaV0FB6pqenhCF2sPDgI+dxP+QUv3ax1U9fty1l7 JjM03fCtTknU4OvZPp+wmiGBLqSMgbPODiy0SrLAEjGQgoAV7tMTN62gWqBqsKdqzpNs 7wCXOnC0gjk0yapmSlan7fTr7valGnhxbGWU6l+2+Z/xJ2Yui4n5n6Kz/YMM75StzgvS Dm5QwaJLH2Fjh1uGMtfRoODfKvDHYuAFLkTAr/NUfLnmFwqHYYXwkfov455+8KLonMch iQvaOvtzeoJwa4RHWjys55goJiGgMlSb0fmG9+KQRtpfndVKICjkyTv18iTTtBgELF/V lVmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=43A7OGjLhqaEifz/P+kxVcBBzORhgpqOzOnqTc7kQIs=; b=ZZBC0qkuSKAKotuOuj7b9olNmXC9OH448ZJf/nAYVvAUUw6wOiHeMITGvyLMj/sExe B3lTpaWe0pbMV2ZF5bojKvIy/IlzG/dpFDAnFtsJgHd5AsVW8O4DxWver4TOheB4RXA9 yT/p9MnibA+BRJzwVIbWtKuyMfOwwLl0cOySMcAuv2l1VY0oVDYyCg6NM2t4cTMvB9j2 iBnxZ/GcHZ+d/Gozst8NOhKziw6fkNkZcOQFFi+gHWuim9uCubKB/yDB8v1dYMqbGsh+ iQSllY+0xzDQ57WKmk/hgnKjqL9cd0WZzYG+PJb/ShGYvItgeHvCYVdiSlOy2xJD2d0o Cvng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Sy7ZA2kx; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t80-v6si40552189pfe.59.2018.06.11.09.06.02; Mon, 11 Jun 2018 09:06:02 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Sy7ZA2kx; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753123AbeFKQGA (ORCPT + 13 others); Mon, 11 Jun 2018 12:06:00 -0400 Received: from mail-wr0-f194.google.com ([209.85.128.194]:32817 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753583AbeFKQF6 (ORCPT ); Mon, 11 Jun 2018 12:05:58 -0400 Received: by mail-wr0-f194.google.com with SMTP id k16-v6so21012617wro.0 for ; Mon, 11 Jun 2018 09:05:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=43A7OGjLhqaEifz/P+kxVcBBzORhgpqOzOnqTc7kQIs=; b=Sy7ZA2kxs5rpB7ChJk7zGasYFZg7Nm/YgGnbL8RbmgAgeFi2fWqZ+7h49DgKTrt0cY jY7SNqk9k6Uwxe3oATIKp+I2q+1B0iKThcwjjUTEfn2bNFj+h1XeB+HdyQNQLewgUGib m2mIS9Q6O44O56ldbRCaCewwjwoejnUET+1s6VwdgDtPuuC/oConADvXpRFgdSnmwlCs HEMAZ+MuecDQzgtTOYBOhS0uin/9J7mNllO/wOT/uU80UPFjGsP1nYmFju2YS5BA1jDJ 27zNr6x1Hj2xPoQkjOTcQBEIwawnY1n1UKe9aXy/Tb5UxgHKHn64+CLDqPMu0Esvmbeg CvUw== 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; bh=43A7OGjLhqaEifz/P+kxVcBBzORhgpqOzOnqTc7kQIs=; b=DVvR9sBT4rUAZ6m/O8Du5wyfQCiqnqHbIXRCNea1LCTEE5drpZ2bxELC2DDnAmFJSr 42Scq3DRPtfYfjPFe+OnQykCeNRCnQuhzId/6lAh8ATtqWM5/J+JtwK86CKkKrFGBRxa ZSc3oCSI7nL0o6/P6cKpMfUUVMw4AR05ncakVIzMD/ljc1DQdfWiJNiTF9xmcYigcAac VkE+rRbEmkzzG7ykjpRteR0oopXpiWTiUQ3MmcKQC4Nw4NtAgIcsnFfQSdBnFZGxbAMO 5vilnN6OlORWfLx3BD9Bxm7ApBRnuNFdFNFHhBHmP/wQ0UyECkNMzTD7H4WQ75etSPwM XrnA== X-Gm-Message-State: APt69E00BQCpBei6TqgIh7yT+OGenRZEAGnn0ec8DkDAkyyANnGr5X3P kbDSuomu2ipgIHwsHiYxVAU= X-Received: by 2002:adf:d250:: with SMTP id o16-v6mr12960777wri.59.1528733157192; Mon, 11 Jun 2018 09:05:57 -0700 (PDT) Received: from flashbox.your-server.de ([2a01:4f8:10b:24a5::2]) by smtp.gmail.com with ESMTPSA id e81-v6sm11249799wmi.28.2018.06.11.09.05.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Jun 2018 09:05:56 -0700 (PDT) From: Nathan Chancellor To: Greg Kroah-Hartman , stable@vger.kernel.org Cc: Arnd Bergmann , Mike Snitzer , Nathan Chancellor Subject: [PATCH 4.9] dm bufio: avoid false-positive Wmaybe-uninitialized warning Date: Mon, 11 Jun 2018 09:05:33 -0700 Message-Id: <20180611160533.26606-1-natechancellor@gmail.com> X-Mailer: git-send-email 2.17.1 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Arnd Bergmann commit 590347e4000356f55eb10b03ced2686bd74dab40 upstream. gcc-6.3 and earlier show a new warning after a seemingly unrelated change to the arm64 PAGE_KERNEL definition: In file included from drivers/md/dm-bufio.c:14:0: drivers/md/dm-bufio.c: In function 'alloc_buffer': include/linux/sched/mm.h:182:56: warning: 'noio_flag' may be used uninitialized in this function [-Wmaybe-uninitialized] current->flags = (current->flags & ~PF_MEMALLOC_NOIO) | flags; ^ The same warning happened earlier on linux-3.18 for MIPS and I did a workaround for that, but now it's come back. gcc-7 and newer are apparently smart enough to figure this out, and other architectures don't show it, so the best I could come up with is to rework the caller slightly in a way that makes it obvious enough to all arm64 compilers what is happening here. Fixes: 41acec624087 ("arm64: kpti: Make use of nG dependent on arm64_kernel_unmapped_at_el0()") Link: https://patchwork.kernel.org/patch/9692829/ Cc: stable@vger.kernel.org Signed-off-by: Arnd Bergmann [snitzer: moved declarations inside conditional, altered vmalloc return] Signed-off-by: Mike Snitzer [nc: Backport to 4.9, adjust context for lack of 19809c2da28a] Signed-off-by: Nathan Chancellor --- Hi Greg, Resending this with a proper prefix and message, in case the other one fell through the cracks. I came across this warning when building with Google's stock GCC 4.9 toolchain on the OnePlus 6. Context was adjusted around lack of commit 19809c2da28a ("mm, vmalloc: use __GFP_HIGHMEM implicitly") in 4.9. Please apply when you get a chance. Thanks! Nathan drivers/md/dm-bufio.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) -- 2.17.1 diff --git a/drivers/md/dm-bufio.c b/drivers/md/dm-bufio.c index 3ec647e8b9c6..35fd57fdeba9 100644 --- a/drivers/md/dm-bufio.c +++ b/drivers/md/dm-bufio.c @@ -373,9 +373,6 @@ static void __cache_size_refresh(void) static void *alloc_buffer_data(struct dm_bufio_client *c, gfp_t gfp_mask, enum data_mode *data_mode) { - unsigned noio_flag; - void *ptr; - if (c->block_size <= DM_BUFIO_BLOCK_SIZE_SLAB_LIMIT) { *data_mode = DATA_MODE_SLAB; return kmem_cache_alloc(DM_BUFIO_CACHE(c), gfp_mask); @@ -399,16 +396,16 @@ static void *alloc_buffer_data(struct dm_bufio_client *c, gfp_t gfp_mask, * all allocations done by this process (including pagetables) are done * as if GFP_NOIO was specified. */ + if (gfp_mask & __GFP_NORETRY) { + unsigned noio_flag = memalloc_noio_save(); + void *ptr = __vmalloc(c->block_size, gfp_mask | __GFP_HIGHMEM, + PAGE_KERNEL); - if (gfp_mask & __GFP_NORETRY) - noio_flag = memalloc_noio_save(); - - ptr = __vmalloc(c->block_size, gfp_mask | __GFP_HIGHMEM, PAGE_KERNEL); - - if (gfp_mask & __GFP_NORETRY) memalloc_noio_restore(noio_flag); + return ptr; + } - return ptr; + return __vmalloc(c->block_size, gfp_mask | __GFP_HIGHMEM, PAGE_KERNEL); } /*