From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.3 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9B76CC433E0 for ; Fri, 19 Jun 2020 12:43:02 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 600D0207E8 for ; Fri, 19 Jun 2020 12:43:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="H43uf0uw" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 600D0207E8 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 0B7DE8D0099; Fri, 19 Jun 2020 08:43:02 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 068FA8D0089; Fri, 19 Jun 2020 08:43:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EE7CA8D0099; Fri, 19 Jun 2020 08:43:01 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0207.hostedemail.com [216.40.44.207]) by kanga.kvack.org (Postfix) with ESMTP id D7D4D8D0089 for ; Fri, 19 Jun 2020 08:43:01 -0400 (EDT) Received: from smtpin15.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 8F9A4180AD806 for ; Fri, 19 Jun 2020 12:43:01 +0000 (UTC) X-FDA: 76945926162.15.song06_5e0d6e726e19 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin15.hostedemail.com (Postfix) with ESMTP id 5B96F1814B0C1 for ; Fri, 19 Jun 2020 12:43:01 +0000 (UTC) X-HE-Tag: song06_5e0d6e726e19 X-Filterd-Recvd-Size: 7649 Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by imf49.hostedemail.com (Postfix) with ESMTP for ; Fri, 19 Jun 2020 12:43:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1592570579; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Gv76+7wPlxv1JgTAX5XGbER7AaxLFtv8PFB7E49p9nI=; b=H43uf0uwoeXknLW9pepo4I0cOx3Ox3KbVctByKedQckMee34BMNiuYoC/p2LZ/psvgCQnF FsElpvJyPxBcYjp4nv+oNOAJ3cNzPI5RgSGgQ/U6Eodb7TVTCKUtVD3q/LUcO+mJOQBTFx PyfvFdYuSnOjcthIPrDavi5fgkzAKAg= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-433-7Wo61-9uPoqvi1tbAT48UA-1; Fri, 19 Jun 2020 08:42:56 -0400 X-MC-Unique: 7Wo61-9uPoqvi1tbAT48UA-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6060E1005512; Fri, 19 Jun 2020 12:42:53 +0000 (UTC) Received: from localhost (ovpn-12-50.pek2.redhat.com [10.72.12.50]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8212B71671; Fri, 19 Jun 2020 12:42:51 +0000 (UTC) Date: Fri, 19 Jun 2020 20:42:48 +0800 From: Baoquan He To: Nitin Gupta Cc: Andrew Morton , Nitin Gupta , Luis Chamberlain , Kees Cook , Iurii Zaikin , Vlastimil Babka , Joonsoo Kim , open list , "open list:PROC SYSCTL" , "open list:MEMORY MANAGEMENT" Subject: Re: [PATCH] mm: Use unsigned types for fragmentation score Message-ID: <20200619124248.GF3346@MiWiFi-R3L-srv> References: <20200618010319.13159-1-nigupta@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200618010319.13159-1-nigupta@nvidia.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Rspamd-Queue-Id: 5B96F1814B0C1 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam03 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: On 06/17/20 at 06:03pm, Nitin Gupta wrote: > Proactive compaction uses per-node/zone "fragmentation score" which > is always in range [0, 100], so use unsigned type of these scores > as well as for related constants. > > Signed-off-by: Nitin Gupta Reviewed-by: Baoquan He > --- > include/linux/compaction.h | 4 ++-- > kernel/sysctl.c | 2 +- > mm/compaction.c | 18 +++++++++--------- > mm/vmstat.c | 2 +- > 4 files changed, 13 insertions(+), 13 deletions(-) > > diff --git a/include/linux/compaction.h b/include/linux/compaction.h > index 7a242d46454e..25a521d299c1 100644 > --- a/include/linux/compaction.h > +++ b/include/linux/compaction.h > @@ -85,13 +85,13 @@ static inline unsigned long compact_gap(unsigned int order) > > #ifdef CONFIG_COMPACTION > extern int sysctl_compact_memory; > -extern int sysctl_compaction_proactiveness; > +extern unsigned int sysctl_compaction_proactiveness; > extern int sysctl_compaction_handler(struct ctl_table *table, int write, > void *buffer, size_t *length, loff_t *ppos); > extern int sysctl_extfrag_threshold; > extern int sysctl_compact_unevictable_allowed; > > -extern int extfrag_for_order(struct zone *zone, unsigned int order); > +extern unsigned int extfrag_for_order(struct zone *zone, unsigned int order); > extern int fragmentation_index(struct zone *zone, unsigned int order); > extern enum compact_result try_to_compact_pages(gfp_t gfp_mask, > unsigned int order, unsigned int alloc_flags, > diff --git a/kernel/sysctl.c b/kernel/sysctl.c > index 58b0a59c9769..40180cdde486 100644 > --- a/kernel/sysctl.c > +++ b/kernel/sysctl.c > @@ -2833,7 +2833,7 @@ static struct ctl_table vm_table[] = { > { > .procname = "compaction_proactiveness", > .data = &sysctl_compaction_proactiveness, > - .maxlen = sizeof(int), > + .maxlen = sizeof(sysctl_compaction_proactiveness), > .mode = 0644, > .proc_handler = proc_dointvec_minmax, > .extra1 = SYSCTL_ZERO, > diff --git a/mm/compaction.c b/mm/compaction.c > index ac2030814edb..45fd24a0ea0b 100644 > --- a/mm/compaction.c > +++ b/mm/compaction.c > @@ -53,7 +53,7 @@ static inline void count_compact_events(enum vm_event_item item, long delta) > /* > * Fragmentation score check interval for proactive compaction purposes. > */ > -static const int HPAGE_FRAG_CHECK_INTERVAL_MSEC = 500; > +static const unsigned int HPAGE_FRAG_CHECK_INTERVAL_MSEC = 500; > > /* > * Page order with-respect-to which proactive compaction > @@ -1890,7 +1890,7 @@ static bool kswapd_is_running(pg_data_t *pgdat) > * ZONE_DMA32. For smaller zones, the score value remains close to zero, > * and thus never exceeds the high threshold for proactive compaction. > */ > -static int fragmentation_score_zone(struct zone *zone) > +static unsigned int fragmentation_score_zone(struct zone *zone) > { > unsigned long score; > > @@ -1906,9 +1906,9 @@ static int fragmentation_score_zone(struct zone *zone) > * the node's score falls below the low threshold, or one of the back-off > * conditions is met. > */ > -static int fragmentation_score_node(pg_data_t *pgdat) > +static unsigned int fragmentation_score_node(pg_data_t *pgdat) > { > - unsigned long score = 0; > + unsigned int score = 0; > int zoneid; > > for (zoneid = 0; zoneid < MAX_NR_ZONES; zoneid++) { > @@ -1921,17 +1921,17 @@ static int fragmentation_score_node(pg_data_t *pgdat) > return score; > } > > -static int fragmentation_score_wmark(pg_data_t *pgdat, bool low) > +static unsigned int fragmentation_score_wmark(pg_data_t *pgdat, bool low) > { > - int wmark_low; > + unsigned int wmark_low; > > /* > * Cap the low watermak to avoid excessive compaction > * activity in case a user sets the proactivess tunable > * close to 100 (maximum). > */ > - wmark_low = max(100 - sysctl_compaction_proactiveness, 5); > - return low ? wmark_low : min(wmark_low + 10, 100); > + wmark_low = max(100U - sysctl_compaction_proactiveness, 5U); > + return low ? wmark_low : min(wmark_low + 10, 100U); > } > > static bool should_proactive_compact_node(pg_data_t *pgdat) > @@ -2604,7 +2604,7 @@ int sysctl_compact_memory; > * aggressively the kernel should compact memory in the > * background. It takes values in the range [0, 100]. > */ > -int __read_mostly sysctl_compaction_proactiveness = 20; > +unsigned int __read_mostly sysctl_compaction_proactiveness = 20; > > /* > * This is the entry point for compacting all nodes via > diff --git a/mm/vmstat.c b/mm/vmstat.c > index 3e7ba8bce2ba..b1de695b826d 100644 > --- a/mm/vmstat.c > +++ b/mm/vmstat.c > @@ -1079,7 +1079,7 @@ static int __fragmentation_index(unsigned int order, struct contig_page_info *in > * It is defined as the percentage of pages found in blocks of size > * less than 1 << order. It returns values in range [0, 100]. > */ > -int extfrag_for_order(struct zone *zone, unsigned int order) > +unsigned int extfrag_for_order(struct zone *zone, unsigned int order) > { > struct contig_page_info info; > > -- > 2.27.0 > >