Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp2120804rwl; Sun, 26 Mar 2023 16:25:53 -0700 (PDT) X-Google-Smtp-Source: AKy350ZgFJHb1zIuNymSrh2yMEB4Cg+wDenTSfQCRF3qcShm0hgngdrMkC4Gku8sdzywbX/KVryb X-Received: by 2002:a17:903:41c8:b0:19a:7758:e5e6 with SMTP id u8-20020a17090341c800b0019a7758e5e6mr11156139ple.48.1679873153396; Sun, 26 Mar 2023 16:25:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679873153; cv=none; d=google.com; s=arc-20160816; b=jgdrpQpyFNrUWxWCGCsTEnOHnbHTmc+PfI+/hyBqmJ6L0NfypSO4c5iGJHy2JCnsos VjVOH4CdSlvyakgiOV/MB8h3IiFTDwx6vQqtIl38EXwHobzlcgWZAsYCAbmwheVIynws hf/HyHDc0RGZyCIutw4z+ASmINdRrT1u23ZN4edHAqXPF1BSGYG1AK6xxPN+80npI9bO H6avor0y2PnJtOy9Om2RhlupP+vBVbIqRJNGBkkBFhnw57AMNa/RRy3HDE8dkbr6LvJd EZtS/9dIV9qyLpKKKgFwVksgsWGkbg73YvgKRzkeLxuMWp4/Y51b3XU6NG/4NQHIORBZ /zmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=j9UWjMz7h8krVHZXqQuN1VnvQ32WDqohE4ixAuyQ0cw=; b=FUiw4pZZgahQPdbkwfuQyStuwl9o/bqKor5pmhLXVOULKKzMfdTDYJSeRlahlmWjP8 0zd9Z6tclDQoTz4zEx1+/pGqrFVvjpOygxAnSA698sb8pYu9csTske03JiBIQxCM5yJf cGYwExviJYK8MWk5IFmgv+qPTyXX0xXPHyFg1xmFCed5D4fx0zdBawADG8DrVW1UjYYx vQw9Q2kOFsgfL3UuLstRgOyIIfTxv0qexKN7j7eUr6F/aUDA6oMY4Z7IMBthKj9LkjjC lfCIqaFSIB8MCEZEkUJAhsi19afkJ0fb7+0AzCB0n4VVSmG5s1zrx6p/uq0nKeLFx3Lh dBmw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j5-20020a170902da8500b001a1bfe84f8dsi22182608plx.611.2023.03.26.16.25.40; Sun, 26 Mar 2023 16:25:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229546AbjCZXZP (ORCPT + 99 others); Sun, 26 Mar 2023 19:25:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49974 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229456AbjCZXZN (ORCPT ); Sun, 26 Mar 2023 19:25:13 -0400 Received: from verein.lst.de (verein.lst.de [213.95.11.211]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0FC4C46B5 for ; Sun, 26 Mar 2023 16:25:13 -0700 (PDT) Received: by verein.lst.de (Postfix, from userid 2407) id 1016668B05; Mon, 27 Mar 2023 01:25:09 +0200 (CEST) Date: Mon, 27 Mar 2023 01:25:08 +0200 From: Christoph Hellwig To: Sergey Senozhatsky Cc: Liu Shixin , Seth Jennings , Dan Streetman , Vitaly Wool , Andrew Morton , Nathan Chancellor , Christoph Hellwig , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH -next v7 2/4] mm/zswap: skip invalid or unchanged parameter Message-ID: <20230326232508.GB19631@lst.de> References: <20230325071420.2246461-1-liushixin2@huawei.com> <20230325071420.2246461-3-liushixin2@huawei.com> <20230326031723.GD3269998@google.com> <20230326045327.GE3269998@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230326045327.GE3269998@google.com> User-Agent: Mutt/1.5.17 (2007-11-01) X-Spam-Status: No, score=0.0 required=5.0 tests=SPF_HELO_NONE,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Mar 26, 2023 at 01:53:27PM +0900, Sergey Senozhatsky wrote: > > > + if (kstrtobool(val, &res)) > > > + return -EINVAL; > > > + > > > + /* no change required */ > > > + if (res == *(bool *)kp->arg) > > > + return 0; > > > > Bool kernel param can be any of these letters 'YyTt1NnFf0'. Doing things > > to kp->arg outside of kernel/params.c is not going to be easy, let's not > > even try. > > Please disregard my previous email. kp->arg is always true or false > at this point. I'd still prefer to not do kp->arg in zswap. The whole parameter handling in zswap is a mess and I don't really have a good idea how to solve it all. But for this "paramter not changed" case I think we can helper a lot by adding a core moduleparam.h helper to encapsule it. I.e.: static inline bool param_bool_unchanged(bool val, const struct kernel_param *kp) return val == *(bool *)kp->arg); } and at least keep it out of zswap.