From patchwork Fri Jul 13 20:02:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 10524081 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 11933602A0 for ; Fri, 13 Jul 2018 20:02:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F36A029F1D for ; Fri, 13 Jul 2018 20:02:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E6F8129F20; Fri, 13 Jul 2018 20:02:49 +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=unavailable 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 9902429F1D for ; Fri, 13 Jul 2018 20:02:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5D27C6B0003; Fri, 13 Jul 2018 16:02:47 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 582656B0006; Fri, 13 Jul 2018 16:02:47 -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 49B0F6B0007; Fri, 13 Jul 2018 16:02:47 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f198.google.com (mail-pg1-f198.google.com [209.85.215.198]) by kanga.kvack.org (Postfix) with ESMTP id 035796B0003 for ; Fri, 13 Jul 2018 16:02:47 -0400 (EDT) Received: by mail-pg1-f198.google.com with SMTP id g5-v6so2114116pgq.5 for ; Fri, 13 Jul 2018 13:02:46 -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:date:from:to :cc:subject:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=uscQPX+gp9ZdIGnStIHTS8zzsDPpxzE7yhMUOY8shmw=; b=WbVxCeqVRmIIS5iTc3qEm2uD0QN21n8Rpee9TqR7qbJBmdQy9h/X7V1/sMbIvyuqem DlFvLwBHCwIcujYe1Mto8VXnkZI5oII9asLJq+kDDsOpn1NNWvrdbbG4BLfvsY6uOpz0 rHfKHavU3C2Oh3he2OAC1vk25t0OJBfPErKDPKoQt9D80BZjeP4xQ5Z4iq/DinyhPYm2 1GBhuW8pwEYksvM+gY6RkEV7XcLJZkmy5ExD/dKyUYPuJLiEcvw4Gjt4OW9bcUhejZTA hL52yY2L4TFcAOvzhL35IX3tINkh1gXmXx67yT8oX50ff8c40BtZUVliTkXK5p79UHRN 26KQ== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of akpm@linux-foundation.org designates 140.211.169.12 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org X-Gm-Message-State: AOUpUlGLNzzMmv9Y5ot8ZFjlJdvyOI6vYn2/6hEH30Qvrb9pVwFr8/x4 cin1oyE1a9U+jZBnTYj+/rcHOtLfhFbLlfr6FFItD5szrggAAo+AcdCl2Kgyu9c0vICRNaxi6vK gQGWls0kIIMNgNZmaN5xd2NkpbJamXYKRJpFcLq6NttbaEMaP3zyz2xGzrYNPQSIsnQ== X-Received: by 2002:a63:c312:: with SMTP id c18-v6mr7302572pgd.449.1531512166633; Fri, 13 Jul 2018 13:02:46 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdUWtu7LQih/TKzsEG++kWny1WsmWiDon3a32E0OirhbqsAFZ0ccxlBfECrsvdrUKw4W326 X-Received: by 2002:a63:c312:: with SMTP id c18-v6mr7302530pgd.449.1531512165606; Fri, 13 Jul 2018 13:02:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531512165; cv=none; d=google.com; s=arc-20160816; b=hUj/U/vc6b6UeazlJleHGZFXbADguN38kLRiyzj2HZ02/IEvS9M8rbJpu7jVWdGmAg eqLIoUrrZnuDGMfXRTQ1HcOTf3VwwoPlq0lP9YkAXtMVd2yu03qmjVwtkk2ZToLCrMJ4 QcLK4dSm2HL5LK8BwAQ5zFneftyxLcRInlhJma4i6v4Hr8k8oiXuRLIlxs0nzpHgf0K3 a7u8gLNykET/32mB7hyKvmFjTLVGUSozbUT5uzq5DOQN7oYfLuTWhWg60+FEyKxdZXbl ZWIuVaNg6Kh6+yxtlrDJqFRSi6WaZiBLu6IzsSrVqz9uj4cSZXstaQFpwM9j7lMgZv7X gcHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:arc-authentication-results; bh=uscQPX+gp9ZdIGnStIHTS8zzsDPpxzE7yhMUOY8shmw=; b=UcShQVqAsFaA+BbCJk9VVu65XfTtpsODLolwoZVgkBKSiSsd239FAuXGW1LPzceEye QpCFW34WAx2tiB4I2slCFgGAPA88xuS0RfJiDDPuEy19j+iukxPuMdyljFLXizJk/W6G 5LpNG/NQB7yqIbNVL4Hh3SPsaF248Zybl2gG9cvolWCf+EdNqCfpDwErEBk6Sk1mr0Ry UmexTcDbTdbhAg6C0yNsogAh8dCKFQEYe6tis/TNZ5IwvW8a+LPGbkUvme87I7JcC7Dr dgfsAjvXDo6ThPQDhv1YIemHWmrDoeNVTDcuYt2uan7uFuiOJcffGRRMhFBFCIukc0cB MU3g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of akpm@linux-foundation.org designates 140.211.169.12 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org Received: from mail.linuxfoundation.org (mail.linuxfoundation.org. [140.211.169.12]) by mx.google.com with ESMTPS id a5-v6si26719104pll.412.2018.07.13.13.02.45 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Jul 2018 13:02:45 -0700 (PDT) Received-SPF: pass (google.com: domain of akpm@linux-foundation.org designates 140.211.169.12 as permitted sender) client-ip=140.211.169.12; Authentication-Results: mx.google.com; spf=pass (google.com: domain of akpm@linux-foundation.org designates 140.211.169.12 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org Received: from akpm3.svl.corp.google.com (unknown [104.133.9.92]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id A4DD0AF8; Fri, 13 Jul 2018 20:02:44 +0000 (UTC) Date: Fri, 13 Jul 2018 13:02:43 -0700 From: Andrew Morton To: Pavel Tatashin Cc: Oscar Salvador , steven.sistare@oracle.com, daniel.m.jordan@oracle.com, linux-kernel@vger.kernel.org, kirill.shutemov@linux.intel.com, mhocko@suse.com, linux-mm@kvack.org, dan.j.williams@intel.com, jack@suse.cz, jglisse@redhat.com, jrdr.linux@gmail.com, bhe@redhat.com, gregkh@linuxfoundation.org, vbabka@suse.cz, richard.weiyang@gmail.com, dave.hansen@intel.com, rientjes@google.com, mingo@kernel.org, abdhalee@linux.vnet.ibm.com, mpe@ellerman.id.au Subject: Re: [PATCH v5 1/5] mm/sparse: abstract sparse buffer allocations Message-Id: <20180713130243.13d02e94bedc8cc3caf275ca@linux-foundation.org> In-Reply-To: <23f6e4e5-6e32-faf6-433d-67e50d2895a2@oracle.com> References: <20180712203730.8703-1-pasha.tatashin@oracle.com> <20180712203730.8703-2-pasha.tatashin@oracle.com> <20180713131749.GA16765@techadventures.net> <23f6e4e5-6e32-faf6-433d-67e50d2895a2@oracle.com> X-Mailer: Sylpheed 3.6.0 (GTK+ 2.24.31; x86_64-pc-linux-gnu) Mime-Version: 1.0 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 On Fri, 13 Jul 2018 09:24:44 -0400 Pavel Tatashin wrote: > On 07/13/2018 09:17 AM, Oscar Salvador wrote: > > On Thu, Jul 12, 2018 at 04:37:26PM -0400, Pavel Tatashin wrote: > >> +static void *sparsemap_buf __meminitdata; > >> +static void *sparsemap_buf_end __meminitdata; > >> + > >> +void __init sparse_buffer_init(unsigned long size, int nid) > >> +{ > >> + BUG_ON(sparsemap_buf); > > > > Why do we need a BUG_ON() here? > > Looking at the code I cannot really see how we can end up with sparsemap_buf being NULL. > > Is it just for over-protection? > > This checks that we do not accidentally leak memory by calling sparse_buffer_init() consequently without sparse_buffer_fini() in-between. A memory leak isn't serious enough to justify crashing the kernel. Therefore --- a/mm/sparse.c~mm-sparse-abstract-sparse-buffer-allocations-fix-fix +++ a/mm/sparse.c @@ -469,7 +469,7 @@ static void *sparsemap_buf_end __meminit void __init sparse_buffer_init(unsigned long size, int nid) { - BUG_ON(sparsemap_buf); + WARN_ON(sparsemap_buf); /* forgot to call sparse_buffer_fini()? */ sparsemap_buf = memblock_virt_alloc_try_nid_raw(size, PAGE_SIZE, __pa(MAX_DMA_ADDRESS),