Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp7582669imm; Thu, 28 Jun 2018 06:14:38 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJ15bTP/5Vav1q2EopUr1H185BEEXyQ7y/7bv5T/ndbExe948WdcoSLyEsRk7HElHTuDYRh X-Received: by 2002:a17:902:5602:: with SMTP id h2-v6mr10597308pli.314.1530191678480; Thu, 28 Jun 2018 06:14:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530191678; cv=none; d=google.com; s=arc-20160816; b=ZtFinOc7uHx851dsGxlVJWDrtaWQzaGfhY76K49J/pbnW4pxgBUXTnvxx3Rx4PFZdE wBIF/WIu7qzRZH9KlChWQ5lBKBC3rWxbGYn2hiM/yHr9um2Q5o4DmcPQCD2xm5rEw23C b93ikbwJxGj/3O4FLgOXYuDHTMJJ45AP2/L9Dn6O3KoC0y2qnZQUW7SXOy4WgrVNYbcP Dm+591E2GusR8g4nWcz/hJT1eTMNtArQsEO9NC+ZJLUXVxb4FZjHl62nFfgSAJJG8KxX KGJmgWdyHJ9OyGbDLTuEjI95e0visj0VasWyUopMxrPuLD7GdR0G6q18mKKZ0IiORhiU tn2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=Nh1TkwtXyKtA2dv/BEM/kQ0MyrT0/WL4TDQjriYtqZw=; b=Vz3iTFzXHR6050a/6VJFlMxNiqiTNlKmJENUdDZxrBzNYpQYBrIF8bqP5uU88BJqEY ceryiSmrLoMY75YJ83i/+11kTM2jsZTwMGp3ynEE9O4WZQcNTqOxH2zfg2Z2uV5z01Z0 ALwkr+gxmGgGABb92wswNCAygoiazanLN2sszrz2u+UYlA7/kFP5Pn5g0jbZi+XDH/nt WEhYy1U+k1rgChPpEMEbQVAEKle3dbz9dOyOAoJBlJaQOL8ZYqmdOINXIXwFo9Dxx2/G JubTC1UGCkwDPwG2ZbPjQ6lkobjOk+QlbjtnZwrV9jxlmomxV12fJgKXGkTwHheqgmB7 GYoQ== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t4-v6si6308324plo.235.2018.06.28.06.14.15; Thu, 28 Jun 2018 06:14:38 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966157AbeF1NM5 (ORCPT + 99 others); Thu, 28 Jun 2018 09:12:57 -0400 Received: from mail-wr0-f194.google.com ([209.85.128.194]:44518 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965423AbeF1NMy (ORCPT ); Thu, 28 Jun 2018 09:12:54 -0400 Received: by mail-wr0-f194.google.com with SMTP id p12-v6so5468542wrn.11 for ; Thu, 28 Jun 2018 06:12:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=Nh1TkwtXyKtA2dv/BEM/kQ0MyrT0/WL4TDQjriYtqZw=; b=cWMKIzyVA9BvfWcBP98crJWzN3kSu2BhV3fReswBisWkDzLJB70UPj4hv0p0x0hTGl 0/gRyHfRNjQsLy0Lvcqf9jGzAXyPmf3k4SrQu4Gw5L3VWjnOSbrpILoOhGto9112Uac0 Ud5sVtOeLlzUP9WkO5CqMbO+3KRoo9Qd/3Dk8K8MW+FIzT33kh3BjVb5Rei9Z51NyPU8 KSyn03ceY5diXfQLs+u+xCbiJf1oN9FCoVXi1RDs/jx/j8TzZ6CoYNrAW5DDyqmdA2ho nVmvGbpfSceN7PquxIQNB2vNn26dPowiJnxqHu3epKIlNBw2W/3pn4Cgc0JNZAcw1fO5 I6ew== X-Gm-Message-State: APt69E0kAQNaXep+ZseYTarb2hzAzPVqMxJYwBNdfCt0+Gc8jimByZvy MlIeIqFaKLptkKWNctmnGOo= X-Received: by 2002:adf:984e:: with SMTP id v72-v6mr8668090wrb.180.1530191573857; Thu, 28 Jun 2018 06:12:53 -0700 (PDT) Received: from techadventures.net (techadventures.net. [62.201.165.239]) by smtp.gmail.com with ESMTPSA id r7-v6sm24002wrn.83.2018.06.28.06.12.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Jun 2018 06:12:53 -0700 (PDT) Received: by techadventures.net (Postfix, from userid 1000) id A9A7A12391A; Thu, 28 Jun 2018 15:12:52 +0200 (CEST) Date: Thu, 28 Jun 2018 15:12:52 +0200 From: Oscar Salvador To: Pavel Tatashin Cc: bhe@redhat.com, LKML , Andrew Morton , dave.hansen@intel.com, pagupta@redhat.com, Linux Memory Management List , kirill.shutemov@linux.intel.com Subject: Re: [PATCH v6 4/5] mm/sparse: Optimize memmap allocation during sparse_init() Message-ID: <20180628131252.GB13985@techadventures.net> References: <20180628062857.29658-1-bhe@redhat.com> <20180628062857.29658-5-bhe@redhat.com> <20180628120937.GC12956@techadventures.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jun 28, 2018 at 08:12:04AM -0400, Pavel Tatashin wrote: > > > + if (nr_consumed_maps >= nr_present_sections) { > > > + pr_err("nr_consumed_maps goes beyond nr_present_sections\n"); > > > + break; > > > + } > > > > Hi Baoquan, > > > > I am sure I am missing something here, but is this check really needed? > > > > I mean, for_each_present_section_nr() only returns the section nr if the section > > has been marked as SECTION_MARKED_PRESENT. > > That happens in memory_present(), where now we also increment nr_present_sections whenever > > we find a present section. > > > > So, for_each_present_section_nr() should return the same nr of section as nr_present_sections. > > Since we only increment nr_consumed_maps once in the loop, I am not so sure we can > > go beyond nr_present_sections. > > > > Did I overlook something? > > You did not, this is basically a safety check. A BUG_ON() would be > better here. As, this something that should really not happening, and > would mean a bug in the current project. I think we would be better off having a BUG_ON() there. Otherwise the system can go sideways later on. -- Oscar Salvador SUSE L3