Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp737201imu; Tue, 20 Nov 2018 06:15:18 -0800 (PST) X-Google-Smtp-Source: AFSGD/WsX1mIYo64BLAFz6z7Ul/yDNjUAeLHP1+XE9PSi6y0cr9q8F3fH/aGklGdnUxNLVbZv7YG X-Received: by 2002:a63:6cc8:: with SMTP id h191mr1980957pgc.366.1542723318351; Tue, 20 Nov 2018 06:15:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542723318; cv=none; d=google.com; s=arc-20160816; b=q4xWNGBv+3uf5eUqyvtoYWbZX1LSzWRm//GL9rp9NxqRDqLEDcs64F+YfnSlbhrmVm g6LgXYnxhdzXh4C6EgLJ5eSg1p1H/xAmzA4+o13BdTomc6iT1LGNbKRUOzM6EZ343MmC 1xm+g306ynPZNKLpiUPbat5l0jtpOEtpDz6V9D72xIQWEyizidkkvj2TmSkXtyimGXoO Bh/x+Y7G1r+zDj7vLx03KHXj7iOnDpBa/TMu6HhkrnwIWk5TnWpcqP+dFC+G1LWjeypm FUKjY/qu1u125UCiNRTTKMiiAvbzDH/dMQR0CwS1tiKbGqsQhzl7QnOZrJQ554YjSvDA y6kA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=beNsSMozMmZ+5CfHCo99BeS6JRY+tFSz19pv1ZT1bX4=; b=NlaTKrXrE2irCoq+t4s6qh77b+b0l95dsL1KDBBZxo37oSKtjtLtD0eN9/QfYME7AN ffEvXm26QDTVqGmmP9PiEbk09ilOA1k4Huvlc6r1I+TgPscIOvCmr2Olt7ijq383ACVe kZQU0vyEfhqO6PyxwBIArR+NSBzi/shqWtaMAJDNvpCNXXUWo1dbUl0Nw4cwWnKSbF9U vaTDmPlunRazHSX6dZxIvhgSwMIFuQhLnJwpBXAvveNhDaLdt73kTZX9eV45SmIVD55w A+pert3rfNsJ/lSJLYHYl5Qc8vL+W2VjAftR8AdJgOzMNVVgR6/lVytbNCDiyFEODX+L tQvg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l81si13382408pfj.230.2018.11.20.06.15.03; Tue, 20 Nov 2018 06:15:18 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728505AbeKUAnJ (ORCPT + 99 others); Tue, 20 Nov 2018 19:43:09 -0500 Received: from charlotte.tuxdriver.com ([70.61.120.58]:38015 "EHLO smtp.tuxdriver.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725995AbeKUAnJ (ORCPT ); Tue, 20 Nov 2018 19:43:09 -0500 Received: from [107.15.85.130] (helo=localhost) by smtp.tuxdriver.com with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.63) (envelope-from ) id 1gOqtQ-0005Db-UN; Mon, 19 Nov 2018 16:15:43 -0500 Date: Tue, 20 Nov 2018 09:13:29 -0500 From: Neil Horman To: Corentin Labbe Cc: davem@davemloft.net, ebiggers@kernel.org, herbert@gondor.apana.org.au, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 01/10] crypto: crypto_user_stat: made crypto_user_stat optional Message-ID: <20181120141329.GC20562@hmswarspite.think-freely.org> References: <1542717146-34917-1-git-send-email-clabbe@baylibre.com> <1542717146-34917-2-git-send-email-clabbe@baylibre.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1542717146-34917-2-git-send-email-clabbe@baylibre.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Score: 0.3 (/) X-Spam-Status: No Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Nov 20, 2018 at 12:32:17PM +0000, Corentin Labbe wrote: > Even if CRYPTO_STATS is set to n, some part of CRYPTO_STATS are > compiled. > This patch made all part of crypto_user_stat uncompiled in that case. > > Signed-off-by: Corentin Labbe > --- > crypto/Makefile | 3 ++- > crypto/algapi.c | 2 ++ > include/crypto/internal/cryptouser.h | 17 +++++++++++++++++ > include/linux/crypto.h | 2 ++ > 4 files changed, 23 insertions(+), 1 deletion(-) > > diff --git a/crypto/Makefile b/crypto/Makefile > index abbd86fdbad2..22f9f84f961d 100644 > --- a/crypto/Makefile > +++ b/crypto/Makefile > @@ -54,7 +54,8 @@ cryptomgr-y := algboss.o testmgr.o > > obj-$(CONFIG_CRYPTO_MANAGER2) += cryptomgr.o > obj-$(CONFIG_CRYPTO_USER) += crypto_user.o > -crypto_user-y := crypto_user_base.o crypto_user_stat.o > +crypto_user-y := crypto_user_base.o > +crypto_user-$(CONFIG_CRYPTO_STATS) += crypto_user_stat.o > obj-$(CONFIG_CRYPTO_CMAC) += cmac.o > obj-$(CONFIG_CRYPTO_HMAC) += hmac.o > obj-$(CONFIG_CRYPTO_VMAC) += vmac.o > diff --git a/crypto/algapi.c b/crypto/algapi.c > index 2545c5f89c4c..f5396c88e8cd 100644 > --- a/crypto/algapi.c > +++ b/crypto/algapi.c > @@ -258,6 +258,7 @@ static struct crypto_larval *__crypto_register_alg(struct crypto_alg *alg) > list_add(&alg->cra_list, &crypto_alg_list); > list_add(&larval->alg.cra_list, &crypto_alg_list); > > +#ifdef CONFIG_CRYPTO_STATS > atomic_set(&alg->encrypt_cnt, 0); > atomic_set(&alg->decrypt_cnt, 0); > atomic64_set(&alg->encrypt_tlen, 0); > @@ -265,6 +266,7 @@ static struct crypto_larval *__crypto_register_alg(struct crypto_alg *alg) > atomic_set(&alg->verify_cnt, 0); > atomic_set(&alg->cipher_err_cnt, 0); > atomic_set(&alg->sign_cnt, 0); > +#endif > If you created a helper function in crypto_user_stat.c to initalize all the stats, you could ifdef it in the cryptouser.h header if unconfigured, and avoid the ifdef leakage to this file above. Neil > out: > return larval; > diff --git a/include/crypto/internal/cryptouser.h b/include/crypto/internal/cryptouser.h > index 8db299c25566..3492ab42eefb 100644 > --- a/include/crypto/internal/cryptouser.h > +++ b/include/crypto/internal/cryptouser.h > @@ -3,6 +3,23 @@ > > struct crypto_alg *crypto_alg_match(struct crypto_user_alg *p, int exact); > > +#ifdef CONFIG_CRYPTO_STATS > int crypto_dump_reportstat(struct sk_buff *skb, struct netlink_callback *cb); > int crypto_reportstat(struct sk_buff *in_skb, struct nlmsghdr *in_nlh, struct nlattr **attrs); > int crypto_dump_reportstat_done(struct netlink_callback *cb); > +#else > +static int crypto_dump_reportstat(struct sk_buff *skb, struct netlink_callback *cb) > +{ > + return -ENOTSUPP; > +} > + > +static int crypto_reportstat(struct sk_buff *in_skb, struct nlmsghdr *in_nlh, struct nlattr **attrs) > +{ > + return -ENOTSUPP; > +} > + > +static int crypto_dump_reportstat_done(struct netlink_callback *cb) > +{ > + return -ENOTSUPP; > +} > +#endif > diff --git a/include/linux/crypto.h b/include/linux/crypto.h > index 3634ad6fe202..3e05053b8d57 100644 > --- a/include/linux/crypto.h > +++ b/include/linux/crypto.h > @@ -515,6 +515,7 @@ struct crypto_alg { > > struct module *cra_module; > > +#ifdef CONFIG_CRYPTO_STATS > union { > atomic_t encrypt_cnt; > atomic_t compress_cnt; > @@ -552,6 +553,7 @@ struct crypto_alg { > atomic_t compute_shared_secret_cnt; > }; > atomic_t sign_cnt; > +#endif /* CONFIG_CRYPTO_STATS */ > > } CRYPTO_MINALIGN_ATTR; > > -- > 2.18.1 > >