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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 39AE3C7619A for ; Sun, 26 Mar 2023 23:25:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229601AbjCZXZP (ORCPT ); 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) 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.