Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp780307imm; Fri, 22 Jun 2018 05:16:14 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLBVZb2QpZuQMhm+sd79f3jVux2LPCIbeDRLplVIRXT3PmjoFmIV/TvFEI7d0ozwZ39fHaz X-Received: by 2002:a17:902:654c:: with SMTP id d12-v6mr1476038pln.8.1529669774446; Fri, 22 Jun 2018 05:16:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529669774; cv=none; d=google.com; s=arc-20160816; b=0FHdWzE0QDhfPRXy7GGAXZHxdGUrQ6JJQkudOTM0qMEBy+kri/uu0jIgwshz67Dx9V ZB1M1iUHP6SCulfKzw6A9N8bcCmaQ3eHEeAe41wMiUBbp4gXfJtGXGjFxNUGjo80eAol nIbzmaGiCYWtzU7+yYTLIJ+UVw4qk/j/a8dFZ3973Ruc+c9kbxXfLFXcmi9uJlgscwYn DYxOP5JzQ16ptlRN9Gq83qez5XEkZqhgBvt6EnhlKDtR/QqbzIR/MD/do/DP/OuldKjn o4W8ZqauOv849l+W+Duy9olMa+RUQZjghzphruKjRrbUItZnmPSzPs+6XPDOE3W11Nv+ rPMA== 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=ET74fC4EufC/vjHn53nk/xJlrC6o0LAX+swuiT9/q2w=; b=Cl0USOXGVAkcxFW1WR9wAATN2TWW+0V1t6Qv7F/GAAYzah70bbbGnGFJyEEJcOHaOJ HjKwci5EqXvXcqWy3tiuFj5t7QvshM6nEtc0IQ+TVRyfWuKgaCoTbLW6lGZYp5issfr9 sgz2i8QM9xyCq9Fx45S4ezzE8OAfS/d5akRS1W2WzVgjbw0Nu46AzdrPBJw2hxG1ijdv KZbEY8ytD25bf7uAWpPkaN513SKwPLVhjsCsNn39FS+CdzoixVUOUmulZEU6kW+Ymskf yhNxgMNA0KgcOyk6RpF++uh55xqrI97jT98yruBtJe8Q4Ojom1rPn2qGAs38WHhshyMx MNoA== 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m13-v6si6231628pgs.690.2018.06.22.05.15.45; Fri, 22 Jun 2018 05:16:14 -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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751992AbeFVMOy (ORCPT + 99 others); Fri, 22 Jun 2018 08:14:54 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:44780 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751548AbeFVMOw (ORCPT ); Fri, 22 Jun 2018 08:14:52 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7A5B0400786A; Fri, 22 Jun 2018 12:14:51 +0000 (UTC) Received: from localhost (ovpn-8-18.pek2.redhat.com [10.72.8.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C4C1C2026D6B; Fri, 22 Jun 2018 12:14:49 +0000 (UTC) Date: Fri, 22 Jun 2018 20:14:45 +0800 From: Baoquan He To: Ingo Molnar Cc: linux-kernel@vger.kernel.org, lcapitulino@redhat.com, keescook@chromium.org, tglx@linutronix.de, x86@kernel.org, hpa@zytor.com, fanc.fnst@cn.fujitsu.com, yasu.isimatu@gmail.com, indou.takao@jp.fujitsu.com, douly.fnst@cn.fujitsu.com Subject: Re: [PATCH 1/2] x86/boot/KASLR: Add two functions for 1GB huge pages handling Message-ID: <20180622121445.GP29979@MiWiFi-R3L-srv> References: <20180516100532.14083-1-bhe@redhat.com> <20180516100532.14083-2-bhe@redhat.com> <20180621150111.GA23607@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180621150111.GA23607@gmail.com> User-Agent: Mutt/1.9.1 (2017-09-22) X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Fri, 22 Jun 2018 12:14:51 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Fri, 22 Jun 2018 12:14:51 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'bhe@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 06/21/18 at 05:01pm, Ingo Molnar wrote: > > * Baoquan He wrote: > > > +/* Store the number of 1GB huge pages which user specified.*/ > > +static unsigned long max_gb_huge_pages; > > + > > +static int parse_gb_huge_pages(char *param, char* val) > > +{ > > + char *p; > > + u64 mem_size; > > + static bool gbpage_sz = false; > > + > > + if (!strcmp(param, "hugepagesz")) { > > + p = val; > > + mem_size = memparse(p, &p); > > + if (mem_size == PUD_SIZE) { > > + if (gbpage_sz) > > + warn("Repeadly set hugeTLB page size of 1G!\n"); > > + gbpage_sz = true; > > + } else > > + gbpage_sz = false; > > + } else if (!strcmp(param, "hugepages") && gbpage_sz) { > > + p = val; > > + max_gb_huge_pages = simple_strtoull(p, &p, 0); > > + debug_putaddr(max_gb_huge_pages); > > + } > > +} > > This function has at least one style problem and one typo. > > Also, we don't put statics in the middle of function variable blocks. > Sorry, I will check all of them carefully and repost according to your comments. > > +/* Skip as many 1GB huge pages as possible in the passed region. */ > > +static void process_gb_huge_page(struct mem_vector *region, unsigned long image_size) > > +{ > > + int i = 0; > > + unsigned long addr, size; > > + struct mem_vector tmp; > > + > > + if (!max_gb_huge_pages) { > > + store_slot_info(region, image_size); > > + return; > > + } > > + > > + addr = ALIGN(region->start, PUD_SIZE); > > + /* If Did we raise the address above the passed in memory entry? */ > > + if (addr < region->start + region->size) > > + size = region->size - (addr - region->start); > > + > > + /* Check how many 1GB huge pages can be filtered out*/ > > + while (size > PUD_SIZE && max_gb_huge_pages) { > > + size -= PUD_SIZE; > > + max_gb_huge_pages--; > > + i++; > > + } > > + > > + if (!i) { > > + store_slot_info(region, image_size); > > + return; > > + } > > + > > + /* Process the remaining regions after filtering out. */ > > + > > + if (addr >= region->start + image_size) { > > + tmp.start = region->start; > > + tmp.size = addr - region->start; > > + store_slot_info(&tmp, image_size); > > + } > > + > > + size = region->size - (addr - region->start) - i * PUD_SIZE; > > + if (size >= image_size) { > > + tmp.start = addr + i*PUD_SIZE; > > + tmp.size = size; > > + store_slot_info(&tmp, image_size); > > + } > > +} > > I counted about 5 style problems and at least one typo in this function ... > > Please review the code you are submitting more carefully for small details as > well. > > Thanks, > > Ingo