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=-23.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL autolearn=ham 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 6E7B3C12002 for ; Fri, 16 Jul 2021 20:41:29 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id F156F613F1 for ; Fri, 16 Jul 2021 20:41:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F156F613F1 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 357068D00F4; Fri, 16 Jul 2021 16:41:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 306C98D00EC; Fri, 16 Jul 2021 16:41:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1A7E78D00F4; Fri, 16 Jul 2021 16:41:29 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0096.hostedemail.com [216.40.44.96]) by kanga.kvack.org (Postfix) with ESMTP id ED6568D00EC for ; Fri, 16 Jul 2021 16:41:28 -0400 (EDT) Received: from smtpin04.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id B827A250D4 for ; Fri, 16 Jul 2021 20:41:27 +0000 (UTC) X-FDA: 78369621414.04.45F42E7 Received: from mail-ot1-f49.google.com (mail-ot1-f49.google.com [209.85.210.49]) by imf14.hostedemail.com (Postfix) with ESMTP id 810F160022E1 for ; Fri, 16 Jul 2021 20:41:27 +0000 (UTC) Received: by mail-ot1-f49.google.com with SMTP id v32-20020a0568300920b02904b90fde9029so11185243ott.7 for ; Fri, 16 Jul 2021 13:41:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:in-reply-to:message-id:references :mime-version; bh=GWg7KvZek5iHgGcgjBYGZpfEqTpA91OnuHVW1dgUmyk=; b=P/in7RLZw4u1H7lAfXtHYVJrDzt51HXZnpV1rOttAGC0coD1XzQ4LeCMYBgI0t4SG0 SQQQSvA6C+txH0PnhRI92ODNW0GTD33hoUUz2bx1/wuAILbzAeRhpzqzXuWsICT8+RXN 5bk0M8rCUOBGVRHk/4uUg0aZe4/qcO/YCIEw+EwXy/gbvphsOvdWzmDnmXJiplI8K7Ow lqFfkke2+D2Yzxot4SU8boUYq8MUuVOssCqopUme2t7PA04p6J9SWh6tG6bu/an5pIKz Y2iE9SOYsfLmMP2fTwmA36kKYmmhEzwteC57dX8v+q1sf19N6KUZknnArVtXUApCcicO y9TA== 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:in-reply-to:message-id :references:mime-version; bh=GWg7KvZek5iHgGcgjBYGZpfEqTpA91OnuHVW1dgUmyk=; b=MQ9DF7MZIU2IP3WBfZnYISG2sZ3SYMlTTucOLG35d+qvKtAwYc6slrdLI+4dq68YxI 0ZlybH5pn9uupv0O6brZA43svU2kYowuneH7Ni28arID7w+AQ8tbx1ITL4H5dkGAleVc hBdk3zo7z6m5tzilb3BJo12Pk8F9hI2bE+z1ViHF2muwSmjlTZpRI/VoWK04ozTjThw3 Zp+5tIWDi2F6a1yITHOsCxrTa2GdtM+MLH+5fu+MvUT2AR1H2jWhbiHJtK+nlRQs4Xm1 rYJsC5DBscBTSxoemYZVyQcIExggVTa0Taxnk0U0LEmyOf3zcojVHfEP9mV3PmWkSDBx xsfQ== X-Gm-Message-State: AOAM532399Xmtvdyqx0c71r9ngUdkti4SpeEsAfDDT6OPcs37H6Rigcb 6ZXENHV9BSeOCGd6RxoyNKnZOA== X-Google-Smtp-Source: ABdhPJzvQl8z42rkBo8kYI1UMWGkKto8Tj4Cd39VLbpPOLEaInWWqKTLgz4YDxrQf4GRp2lkr+7i6Q== X-Received: by 2002:a9d:61d9:: with SMTP id h25mr5619563otk.81.1626468086638; Fri, 16 Jul 2021 13:41:26 -0700 (PDT) Received: from ripple.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id v8sm2154907oth.69.2021.07.16.13.41.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Jul 2021 13:41:26 -0700 (PDT) Date: Fri, 16 Jul 2021 13:41:24 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@ripple.anvils To: Zhansaya Bagdauletkyzy cc: akpm@linux-foundation.org, tyhicks@linux.microsoft.com, pasha.tatashin@soleen.com, willy@infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] mm: KSM: fix data types In-Reply-To: <20210716055800.GA255851@asus> Message-ID: References: <20210716055800.GA255851@asus> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=google.com header.s=20161025 header.b="P/in7RLZ"; spf=pass (imf14.hostedemail.com: domain of hughd@google.com designates 209.85.210.49 as permitted sender) smtp.mailfrom=hughd@google.com; dmarc=pass (policy=reject) header.from=google.com X-Rspamd-Server: rspam02 X-Stat-Signature: ug949uzunjhdfmn554dqioir9j7hemp9 X-Rspamd-Queue-Id: 810F160022E1 X-HE-Tag: 1626468087-961710 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 Fri, 16 Jul 2021, Zhansaya Bagdauletkyzy wrote: > Change data types of ksm_run and ksm_stable_node_chains_prune_millisecs > as there were a few discrepancies between the types and actual values > that were stored: > 1) ksm_run is declared as unsigned long but in run_store(), it is > converted to unsigned int. Change its type to unsigned int. NAK to that part. Compiling with CONFIG_MEMORY_HOTREMOVE=y would show you why. Search for where ksm_run is used: in one place wait_on_bit(&ksm_run, ilog2(KSM_RUN_OFFLINE), TASK_UNINTERRUPTIBLE); and wait_on_bit() operates on an unsigned long *word. Before that wait while offlining, yes, ksm_run used to be an unsigned int. But there is nothing to be fixed by changing it to an unsigned int now. Save four bytes? Better look elsewhere if you want to save four bytes. > 2) ksm_stable_node_chains_prune_millisecs is declared as int, but in > stable__node_chains_prune_millisecs_store(), it can store values up to > UINT_MAX. Change its type to unsigned int. Ack to that part. > > Signed-off-by: Zhansaya Bagdauletkyzy > --- > v1 -> v2: > - merge two patches into one Sorry, that didn't work out so well. Hugh > > mm/ksm.c | 12 ++++++------ > 1 file changed, 6 insertions(+), 6 deletions(-) > > diff --git a/mm/ksm.c b/mm/ksm.c > index 3fa9bc8a67cf..2e4bd7662e52 100644 > --- a/mm/ksm.c > +++ b/mm/ksm.c > @@ -259,7 +259,7 @@ static unsigned long ksm_stable_node_chains; > static unsigned long ksm_stable_node_dups; > > /* Delay in pruning stale stable_node_dups in the stable_node_chains */ > -static int ksm_stable_node_chains_prune_millisecs = 2000; > +static unsigned int ksm_stable_node_chains_prune_millisecs = 2000; > > /* Maximum number of page slots sharing a stable node */ > static int ksm_max_page_sharing = 256; > @@ -289,7 +289,7 @@ static int ksm_nr_node_ids = 1; > #define KSM_RUN_MERGE 1 > #define KSM_RUN_UNMERGE 2 > #define KSM_RUN_OFFLINE 4 > -static unsigned long ksm_run = KSM_RUN_STOP; > +static unsigned int ksm_run = KSM_RUN_STOP; > static void wait_while_offlining(void); > > static DECLARE_WAIT_QUEUE_HEAD(ksm_thread_wait); > @@ -2874,7 +2874,7 @@ KSM_ATTR(pages_to_scan); > static ssize_t run_show(struct kobject *kobj, struct kobj_attribute *attr, > char *buf) > { > - return sysfs_emit(buf, "%lu\n", ksm_run); > + return sysfs_emit(buf, "%u\n", ksm_run); > } > > static ssize_t run_store(struct kobject *kobj, struct kobj_attribute *attr, > @@ -3105,11 +3105,11 @@ stable_node_chains_prune_millisecs_store(struct kobject *kobj, > struct kobj_attribute *attr, > const char *buf, size_t count) > { > - unsigned long msecs; > + unsigned int msecs; > int err; > > - err = kstrtoul(buf, 10, &msecs); > - if (err || msecs > UINT_MAX) > + err = kstrtouint(buf, 10, &msecs); > + if (err) > return -EINVAL; > > ksm_stable_node_chains_prune_millisecs = msecs; > -- > 2.25.1