From patchwork Fri Jul 16 05:58:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhansaya Bagdauletkyzy X-Patchwork-Id: 12381451 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=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 44015C07E95 for ; Fri, 16 Jul 2021 05:58:08 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D66DB611AB for ; Fri, 16 Jul 2021 05:58:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D66DB611AB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 370CB8D00F4; Fri, 16 Jul 2021 01:58:08 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 320E98D00EC; Fri, 16 Jul 2021 01:58:08 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1C2A38D00F4; Fri, 16 Jul 2021 01:58:08 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0030.hostedemail.com [216.40.44.30]) by kanga.kvack.org (Postfix) with ESMTP id ED5848D00EC for ; Fri, 16 Jul 2021 01:58:07 -0400 (EDT) Received: from smtpin35.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 1FBF28248047 for ; Fri, 16 Jul 2021 05:58:05 +0000 (UTC) X-FDA: 78367395330.35.E3B9602 Received: from mail-lj1-f170.google.com (mail-lj1-f170.google.com [209.85.208.170]) by imf14.hostedemail.com (Postfix) with ESMTP id D121360019AD for ; Fri, 16 Jul 2021 05:58:04 +0000 (UTC) Received: by mail-lj1-f170.google.com with SMTP id e20so12490848ljn.8 for ; Thu, 15 Jul 2021 22:58:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition; bh=UMHofSB6HJnSeyqJoZbABW7A5gujb3us5XO5jkbBEkU=; b=KThkaL8MHL7GEyxa4McnKup2GKMuNBFOJRTUO+PntmAZjmv1reu3uQE+QYdXDLsFuw uh/6bKLX2EbUs/dj6qnQ1WJU8tKuUP94CBuZRABF5UmtamdkpFQnST70wkH3D3KhnLCm 2ls1PlY1WY0SVJ4HSn0M/agPxsgkeedDPjSw1bxSFkHXJsozb8SsnSaUE/rdcMJYHwnM R+CCeXiUDjbjQ02wcwJ9nT9HApNKsgPO4MbHzC2tSdR17D5EVBAjVtvkXPz+9J61B+Tc VX2CAS7cJQHJCOUUSnVsL09poC+o2bihy/WbVyVDf+DGgzOWr8xSbM5kcV/QjknT91nq N8pA== 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:mime-version :content-disposition; bh=UMHofSB6HJnSeyqJoZbABW7A5gujb3us5XO5jkbBEkU=; b=Z7v4rgH/bHPaMxXhyq9fzYwq9TsUtn6qyn+uuWmh2j27DYKYey70iFpoQX9gKrR59D aRQTnrivivkPCfslq4LMXDveaQSXMzs1ms5WQVR7ndKEcEO3eiz4OFCzK5ZZoUg15bnU Mq5Smbr/NXoBURgHOSVaR9FQPcaks05H4on7AsDLztw26kesRwYCDDnB8TXmrJ7d37pj N1B/cCAU54VmFbCSK2dhHdnGfIswBigaflYLIs0Izeh6qcWcepR60VPLJ3ZvojL9FOCU lbU9KrWLliXZac/B1JxhBV0f6ZLzXaxqDOOX19qzWZoLst895reKLxMm0b7mWik/GNbe lNtA== X-Gm-Message-State: AOAM5334+dIc0m3tFGYuIbiUH2/nX8Svi37l3zU2E2jMszZlgEtcIKyq b9uDvWTq92iPJcZmglV/6Sk= X-Google-Smtp-Source: ABdhPJwLSUu7WV9inVDh1Mi5xmt8hlOuKMWJ2apbyIP22ZITV1wVZqXtGYea4gdOt6PzEMJ3rYUlTw== X-Received: by 2002:a2e:bd81:: with SMTP id o1mr1833286ljq.504.1626415083268; Thu, 15 Jul 2021 22:58:03 -0700 (PDT) Received: from asus ([37.151.208.206]) by smtp.gmail.com with ESMTPSA id x74sm564011lff.254.2021.07.15.22.58.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Jul 2021 22:58:02 -0700 (PDT) Date: Fri, 16 Jul 2021 11:58:00 +0600 From: Zhansaya Bagdauletkyzy To: akpm@linux-foundation.org Cc: tyhicks@linux.microsoft.com, pasha.tatashin@soleen.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] mm: KSM: fix data types Message-ID: <20210716055800.GA255851@asus> MIME-Version: 1.0 Content-Disposition: inline Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=KThkaL8M; spf=pass (imf14.hostedemail.com: domain of zhansayabagdaulet@gmail.com designates 209.85.208.170 as permitted sender) smtp.mailfrom=zhansayabagdaulet@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Stat-Signature: ow336qp1dkyff6o99kybnqekekaewrbe X-Rspamd-Queue-Id: D121360019AD X-Rspamd-Server: rspam01 X-HE-Tag: 1626415084-246043 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: 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. 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. Signed-off-by: Zhansaya Bagdauletkyzy --- v1 -> v2: - merge two patches into one 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;