Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp708644pxv; Thu, 15 Jul 2021 14:05:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwf0NKoh8MerahV5dFZjOFplJpmqjK4n0nk/ohZd/3+i8xP+zteKjGdGqHrfH3wnZwBp7Qn X-Received: by 2002:aa7:c14e:: with SMTP id r14mr9602296edp.251.1626383108711; Thu, 15 Jul 2021 14:05:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626383108; cv=none; d=google.com; s=arc-20160816; b=j5jZcLsFgjClM1HzoUW9CBZOZpJk4v2az8sFGTYRG0iK1N9ayevHkcX7watq5h3EFW unl1xv1v/ScF6OFS8i1EfutEXZWckMQRdw53qLEPgYhKxm5SMKXKt6tTg+vLhsbWMWxO GA9qwT52conXcOO1ZKYpp5u/fnrbLJ3Z0MnSppkM/AdVRPoYJ2M0Ele1JvoR83uxvnG2 p7xV8czgaQuRyHpLxDmH4g/zAwUm7hlkR8YTSJj1ogmKvgYxEwXwItfvaOfoUavdTjHp r+ObgwixbYRYG5a2Xg0X5gGpFhTP2HcJV1iZzx5+RweXtMmLGrVXmLt3Ft8BY7qsilyU /dgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=fYKgvYLgvtSQW10Pkkm7+cl/2v+kKNbnHVNtsf/foy4=; b=aZ2IRmxWmONPyKlLzclMR+jZY9/OhfzSCWj6xdT4qOjHGzjyOuKINWNutA3EEfAq5k OSsezvduhQcFgRBt1zp1tmbfu08npeF8wiSAb25wssQ4loqj7AeYVGpCOP7342IFx7VT MupozTJxNMlKoS3sLa19GV+qCyib2JGsAyXUmSo2+u3wDYpK+gC1rraz1dDwFBSyARV1 HwLa6uXn4dMvKH7UDd9ETwUNqqALGq2ULeQJfUa8SxZET1l1xepHSqx8g7MYouaYmbrs 52xI6jvSw9XkxAM6EsUiHrdRtf2zXrCqPW2tfxLUfrlTckDxbfNr7TMS3ZbJV4a+jZfX Spug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@soleen.com header.s=google header.b=I1P8lxvH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h2si8508623ejx.355.2021.07.15.14.04.46; Thu, 15 Jul 2021 14:05:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@soleen.com header.s=google header.b=I1P8lxvH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243746AbhGOTPs (ORCPT + 99 others); Thu, 15 Jul 2021 15:15:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59350 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242284AbhGOTBv (ORCPT ); Thu, 15 Jul 2021 15:01:51 -0400 Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [IPv6:2a00:1450:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 81FF8C0617A6 for ; Thu, 15 Jul 2021 11:58:14 -0700 (PDT) Received: by mail-ej1-x632.google.com with SMTP id c17so10941058ejk.13 for ; Thu, 15 Jul 2021 11:58:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=fYKgvYLgvtSQW10Pkkm7+cl/2v+kKNbnHVNtsf/foy4=; b=I1P8lxvHTr2xXP69nPZ/+7IW0uj06lsFuq2VivGUARKQjT/5ggKxzGM/n1ztJmatLe TivTuUjTr0xe94W6KYF0CnsoTjtYoNL3fhEORVO+D+sr1IcKbUeKmdOXZtn7JjWlq2lC ndCldBAAjucaHQaVBIzY8bnHI15b61gOPyrQBBhncKqmMeCwI1E+z6z35j/8Ch6o1yHr TQpeoAET9IMB86aBuFqGpt6K+m2BMNet9rvWt2Vzpk6dvEfeFR98AJ2l2qlRE7kmFb2v 1oIBGWdwQpP0w8BVr1FVuGhlDBxr52MIK+pj93nepBC0y4FXPK4MWKHfeKBZpIlbgx2l zpsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=fYKgvYLgvtSQW10Pkkm7+cl/2v+kKNbnHVNtsf/foy4=; b=J7eDwomrJiFWwlbl+dMdFX34nU3kdoggUVJ4z12M3f8sCOHqAHDW6nNLPQOfPelYVS BKgAstNYTibfG3SdF8pKNYFZ0s8C8IlaclW6+WkuH5f11gFaJwZb2D+lt25uljgcK8nj FoNEzos/2oKAeKnQRA8SWZGTJP0qQs3nRNlqdj6jE3tnNEt2ppVecdN9ZYiN/IGKWcPz DI0S5bkINDdgdDD74kC8ZDOyVujaa9r7Yp7ag0DSPdgDYXsAwMQedWUTDNGwKk5NeMI7 3kyvUOsJ76HlbnwIjH+lWTCSVS3gv2EOQVdJBXnMFwZ/uyX9+TteUdrYBJkKzm0pYdBp yAGg== X-Gm-Message-State: AOAM530BuaBoEbEu5CFfVjHhI9l26+OIkf2aX5GnFJJsX3Ra/ZwrFE/E YsmCXBkF9wYyUvtU7HY00xAXdXKLlTO3VCoLJSsOKw== X-Received: by 2002:a17:906:8558:: with SMTP id h24mr7138820ejy.519.1626375493122; Thu, 15 Jul 2021 11:58:13 -0700 (PDT) MIME-Version: 1.0 References: <343394260f599d940cacc37f1dcc0309239ae220.1626371112.git.zhansayabagdaulet@gmail.com> In-Reply-To: From: Pavel Tatashin Date: Thu, 15 Jul 2021 14:57:37 -0400 Message-ID: Subject: Re: [PATCH 1/2] mm: KSM: fix ksm_run data type To: Matthew Wilcox Cc: Zhansaya Bagdauletkyzy , Andrew Morton , Tyler Hicks , linux-mm , LKML Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jul 15, 2021 at 2:30 PM Matthew Wilcox wrote: > > On Thu, Jul 15, 2021 at 02:21:21PM -0400, Pavel Tatashin wrote: > > On Thu, Jul 15, 2021 at 2:18 PM Matthew Wilcox wrote: > > > > > > On Fri, Jul 16, 2021 at 12:01:01AM +0600, Zhansaya Bagdauletkyzy wrote: > > > > +++ b/mm/ksm.c > > > > @@ -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; > > > > > > Should this be an enum instead? > > > > I think "unsigned int" is OK here, as it is exposed as uint to users: > > Documentation/ABI/testing/sysfs-kernel-mm-ksm > > > > /sys/kernel/mm/ksm/run > > > > run: write 0 to disable ksm, read 0 while ksm is disabled. > > > > - write 1 to run ksm, read 1 while ksm is running. > > - write 2 to disable ksm and unmerge all its pages. > > The document is out of date then as it does not mention 'offline'. The offline mode cannot be set externally. In run_store() if (flags > KSM_RUN_UNMERGE) return -EINVAL; > > Also, why does the call to kstrtouint() specify base 10? If it is a > bitmap, then permitting 0x [1] is more natural. I would expect to see > base 0 there. Users can only write 0, 1, or 2, it is not a bitmap from the user's perspective as the user cannot write: '3' . But, I think it is somewhat weird that ksm_run is used as a bitmap internally with KSM_RUN_OFFLINE = 4. Imo, KSM_RUN_OFFLINE should be placed in a separate boolean from "ksm_run". > > [1] or even 0b, although I see that _parse_integer_fixup_radix does not > support the 0b notation.