Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp1797184imm; Wed, 10 Oct 2018 23:16:11 -0700 (PDT) X-Google-Smtp-Source: ACcGV60P6LnF2VIB34QPj0P8uMG/LFGESzRaA0UGSjNeC6cwiUdefT0rf1LtSzKMROsSk1SXwQfX X-Received: by 2002:a17:902:ab8a:: with SMTP id f10-v6mr232685plr.203.1539238571739; Wed, 10 Oct 2018 23:16:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539238571; cv=none; d=google.com; s=arc-20160816; b=otLc8qUHYy+egxSa+hS2T6j0sroXY9Cr6p7Xv+tVaBt7XfbDCc7GmQiYa+YEgjv220 us6ppWEksp7C1nVxrFf9ZTW+uPU4aRi1+45KAArzo2WumlgVoDo8pMYXuDiggnrJH4p6 VKKLUf+Jcxfa2C34Fs/mAch6268Yc8cECLOwSURnUnB3irVF+hNyCew81lFm44XEJjPP 3bAqDYY09XW4ORE5sAAOlpkym45XKZrYjXnR8xmHfc6FIcZQkR91mmRzRvgCGve0lvL5 vDvPuDsZcr4O82jk9qau9BZUlYLAbteNO7CGjNFkElDrliTaL9yhF98t3bfj80tvufIl yi3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:user-agent:in-reply-to :content-disposition:mime-version:references:subject:cc:to:from:date; bh=3ggcEVhgjlxNydX384EVjnPbrC2DRemCUeAVXic7Db0=; b=W+PDse2ZC96O1KwgFVuyL+zJbdJAgjI8kPW5qLN1EdeNKLRA9tJHrHC5tpbZJXcgsW 6dGq3apkgWj+ccyZQ7j5ddqV5/cRodgl/vBtP2aX1c8YrX/3g3YquLz9bxQV2ZqnmMpV EGbYdky0uldc8i6XckCMHwaEuSPCLPm/3ut9JExAmPJeWkDoq/v0q0sebysBl9LXEgTz CfvMN5nBkqA67a95HYGewFWvIPt2QfSbF5AKjwKixyPE/Ol1+XPp2RtzJE7a73ab4P35 Gc0YIFL8KMnFvF24rXOtJNByGc+cP58Zj+rfkFiwTaDt3mogkJiBKvTgnJcK7CHFGp9M DB7Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q1-v6si26196586pgs.110.2018.10.10.23.15.57; Wed, 10 Oct 2018 23:16:11 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728144AbeJKNe6 (ORCPT + 99 others); Thu, 11 Oct 2018 09:34:58 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:37468 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728122AbeJKNe6 (ORCPT ); Thu, 11 Oct 2018 09:34:58 -0400 Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w9B69ABw146415 for ; Thu, 11 Oct 2018 02:09:13 -0400 Received: from e06smtp05.uk.ibm.com (e06smtp05.uk.ibm.com [195.75.94.101]) by mx0b-001b2d01.pphosted.com with ESMTP id 2n1yqr2nj7-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 11 Oct 2018 02:09:12 -0400 Received: from localhost by e06smtp05.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 11 Oct 2018 07:09:03 +0100 Received: from b06cxnps3074.portsmouth.uk.ibm.com (9.149.109.194) by e06smtp05.uk.ibm.com (192.168.101.135) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Thu, 11 Oct 2018 07:08:56 +0100 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w9B68sIf1376738 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 11 Oct 2018 06:08:55 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EA939AE053; Thu, 11 Oct 2018 09:07:37 +0100 (BST) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D5101AE057; Thu, 11 Oct 2018 09:07:35 +0100 (BST) Received: from rapoport-lnx (unknown [9.148.207.69]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Thu, 11 Oct 2018 09:07:35 +0100 (BST) Date: Thu, 11 Oct 2018 09:08:50 +0300 From: Mike Rapoport To: Andrew Morton Cc: linux-mm@kvack.org, Catalin Marinas , Chris Zankel , Geert Uytterhoeven , Guan Xuetao , Ingo Molnar , Matt Turner , Michael Ellerman , Michal Hocko , Michal Simek , Paul Burton , Richard Weinberger , Russell King , Thomas Gleixner , Tony Luck , linux-alpha@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-ia64@vger.kernel.org, linux-kernel@vger.kernel.org, linux-m68k@vger.kernel.org, linux-mips@linux-mips.org, linuxppc-dev@lists.ozlabs.org, linux-um@lists.infradead.org Subject: Re: [PATCH] memblock: stop using implicit alignement to SMP_CACHE_BYTES References: <1538687224-17535-1-git-send-email-rppt@linux.vnet.ibm.com> <20181005151934.87226fa92825c3002a475413@linux-foundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181005151934.87226fa92825c3002a475413@linux-foundation.org> User-Agent: Mutt/1.5.24 (2015-08-30) X-TM-AS-GCONF: 00 x-cbid: 18101106-0020-0000-0000-000002D27E1F X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18101106-0021-0000-0000-00002120F47F Message-Id: <20181011060850.GA19822@rapoport-lnx> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-10-11_01:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810110060 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Oct 05, 2018 at 03:19:34PM -0700, Andrew Morton wrote: > On Fri, 5 Oct 2018 00:07:04 +0300 Mike Rapoport wrote: > > > When a memblock allocation APIs are called with align = 0, the alignment is > > implicitly set to SMP_CACHE_BYTES. > > > > Replace all such uses of memblock APIs with the 'align' parameter explicitly > > set to SMP_CACHE_BYTES and stop implicit alignment assignment in the > > memblock internal allocation functions. > > > > For the case when memblock APIs are used via helper functions, e.g. like > > iommu_arena_new_node() in Alpha, the helper functions were detected with > > Coccinelle's help and then manually examined and updated where appropriate. > > > > ... > > > > --- a/mm/memblock.c > > +++ b/mm/memblock.c > > @@ -1298,9 +1298,6 @@ static phys_addr_t __init memblock_alloc_range_nid(phys_addr_t size, > > { > > phys_addr_t found; > > > > - if (!align) > > - align = SMP_CACHE_BYTES; > > - > > Can we add a WARN_ON_ONCE(!align) here? To catch unconverted code > which sneaks in later on. Here it goes: From baec825c58e8bc11371433d3a4b20b2216877a50 Mon Sep 17 00:00:00 2001 From: Mike Rapoport Date: Mon, 8 Oct 2018 11:22:10 +0300 Subject: [PATCH] memblock: warn if zero alignment was requested After update of all memblock users to explicitly specify SMP_CACHE_BYTES alignment rather than use 0, it is still possible that uncovered users may sneak in. Add a WARN_ON_ONCE for such cases. Signed-off-by: Mike Rapoport --- mm/memblock.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mm/memblock.c b/mm/memblock.c index 0bbae56..5fefc70 100644 --- a/mm/memblock.c +++ b/mm/memblock.c @@ -1298,6 +1298,9 @@ static phys_addr_t __init memblock_alloc_range_nid(phys_addr_t size, { phys_addr_t found; + if (WARN_ON_ONCE(!align)) + align = SMP_CACHE_BYTES; + found = memblock_find_in_range_node(size, align, start, end, nid, flags); if (found && !memblock_reserve(found, size)) { @@ -1420,6 +1423,9 @@ static void * __init memblock_alloc_internal( if (WARN_ON_ONCE(slab_is_available())) return kzalloc_node(size, GFP_NOWAIT, nid); + if (WARN_ON_ONCE(!align)) + align = SMP_CACHE_BYTES; + if (max_addr > memblock.current_limit) max_addr = memblock.current_limit; again: -- 2.7.4 -- Sincerely yours, Mike.