Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp2428369rdg; Mon, 16 Oct 2023 04:27:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEvAUrnOV/MTEgeLgL0k3MDWogdjLdhwENKfePGfH0zfhu3monnaVEeOCspiv2SHlKdxIj3 X-Received: by 2002:a05:6a00:17a1:b0:6b5:a01f:f7fd with SMTP id s33-20020a056a0017a100b006b5a01ff7fdmr9894559pfg.0.1697455672021; Mon, 16 Oct 2023 04:27:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697455672; cv=none; d=google.com; s=arc-20160816; b=gQ55s9H7npmizDILGyeSpB7sBz6ZRB+nZWoHBEiMjMXpjSuoJX4Hr9MPLwcpfMmvpw iqr+a8gEEZlyaSDuyULj1IOeL2VwKifxPNECCcPK+VIAiaXd0MiQM0pZ4tstMkn6veTi k1/6SdhR3ZqNEbzx5Gg+owzNqRwlKVzr4/QAP8fg0pw/9Pfz4u+gJuRRocg+APQK3ECp FkOaoSZfUMW3hJjHuKSxxNGOoQuFQ3A8Ql8INr1NY7vpUexJN4qXtZuG+JJzCt4q6ar5 rXELHE9JisKOjHJB+Zz0cbhJefBKDQYEqvTXSEmH0aDdiy/F+mA5ANIPFDiJfHECOReS BK8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:subject:cc:to:from:date :dkim-signature; bh=JqKuV+78moIKwUxlbqTTYbI2edDzIVQgUgE9CeeC/5I=; fh=TJxfGnQeNdnsvlB/lHNd4BvMSkX9233sSPQfBRCC1cY=; b=VL/+baP29q3j5oI47JPOmCp5ZiCnuQEvajuAhHzOSf4/gpfOl5rSDp9+Xcb+vDdda0 U1r2LCkXrnYV6VFqeGFxdBQCiGEU0lEWJffgi6x6s9n9F+YLDn104WdQjgEU/TK41qCd CC6OKr3Iq4qCPxF6NxwwJbOqRL67urx2sUtpm0xIwxaEBJCTfg5/rgEqRkGVaRbwUNFL L1KL82DqaCtgUMYHdl2ULekfgK1iz97fvJwHTRoG3gkNgCkq+FRvtPdN/UN0L3Ai70Hu 5d8dq8jR7s4+JClY4fiWXBxS4gcwuPUMnn5XxQTRhO3/S791zwBGHZMFX86HYPkQRS24 2NqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ep2SGJE1; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id cb6-20020a056a02070600b005b4600b5738si4265271pgb.261.2023.10.16.04.27.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 04:27:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ep2SGJE1; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 8A99F80AD119; Mon, 16 Oct 2023 04:27:49 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232618AbjJPL1k (ORCPT + 99 others); Mon, 16 Oct 2023 07:27:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37874 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232591AbjJPL1j (ORCPT ); Mon, 16 Oct 2023 07:27:39 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D2F7BC5 for ; Mon, 16 Oct 2023 04:26:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697455614; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type; bh=JqKuV+78moIKwUxlbqTTYbI2edDzIVQgUgE9CeeC/5I=; b=ep2SGJE1/e4WlWP/Bu4GYICgJptr2yJdYG4WfmHWSFhxKWVDrOL60fbo0F/oD2iExy06Th lpYQI4kC8gh/i4D1aLhzevfQiSYY84ydCbAJ+Y30ag6XtpvDl8Qyvh3RDVc2UdX6fM0oJx kKQqMRZ4cUc3Gg/69nhnIPhMw2g7dIY= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-448-nudMqxKNPge9LWziV_I9Mw-1; Mon, 16 Oct 2023 07:26:48 -0400 X-MC-Unique: nudMqxKNPge9LWziV_I9Mw-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E18371023111; Mon, 16 Oct 2023 11:26:47 +0000 (UTC) Received: from file1-rdu.file-001.prod.rdu2.dc.redhat.com (unknown [10.11.5.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9B2CDC15BB8; Mon, 16 Oct 2023 11:26:47 +0000 (UTC) Received: by file1-rdu.file-001.prod.rdu2.dc.redhat.com (Postfix, from userid 12668) id 7A03F30C72A3; Mon, 16 Oct 2023 11:26:47 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by file1-rdu.file-001.prod.rdu2.dc.redhat.com (Postfix) with ESMTP id 74F653D99E; Mon, 16 Oct 2023 13:26:47 +0200 (CEST) Date: Mon, 16 Oct 2023 13:26:47 +0200 (CEST) From: Mikulas Patocka To: Herbert Xu , "David S. Miller" , Giovanni Cabiddu cc: linux-crypto@vger.kernel.org, qat-linux@intel.com Subject: [RFC PATCH] crypto: de-prioritize QAT Message-ID: <0171515-7267-624-5a22-238af829698f@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Mon, 16 Oct 2023 04:27:49 -0700 (PDT) Hi I created this kernel module that stress-tests the crypto API: https://people.redhat.com/~mpatocka/benchmarks/qat/tools/module-multithreaded.c It shows that QAT underperforms significantly compared to AES-NI (for large requests it is 10 times slower; for small requests it is even worse) - see the second table in this document: https://people.redhat.com/~mpatocka/benchmarks/qat/kernel-module.txt QAT has higher priority than AES-NI, so the kernel prefers it (it is not used for dm-crypt because it has the flag "CRYPTO_ALG_ALLOCATES_MEMORY", but it is preferred over AES-NI in other cases). AES-NI has priority 300 or 400, unaccelerated AES has 100, so I suggest to lower the priority of QAT from 4001 to 201. Signed-off-by: Mikulas Patocka --- drivers/crypto/intel/qat/qat_common/qat_algs.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) Index: linux-2.6/drivers/crypto/intel/qat/qat_common/qat_algs.c =================================================================== --- linux-2.6.orig/drivers/crypto/intel/qat/qat_common/qat_algs.c +++ linux-2.6/drivers/crypto/intel/qat/qat_common/qat_algs.c @@ -1277,7 +1277,7 @@ static struct aead_alg qat_aeads[] = { { .base = { .cra_name = "authenc(hmac(sha1),cbc(aes))", .cra_driver_name = "qat_aes_cbc_hmac_sha1", - .cra_priority = 4001, + .cra_priority = 201, .cra_flags = CRYPTO_ALG_ASYNC | CRYPTO_ALG_ALLOCATES_MEMORY, .cra_blocksize = AES_BLOCK_SIZE, .cra_ctxsize = sizeof(struct qat_alg_aead_ctx), @@ -1294,7 +1294,7 @@ static struct aead_alg qat_aeads[] = { { .base = { .cra_name = "authenc(hmac(sha256),cbc(aes))", .cra_driver_name = "qat_aes_cbc_hmac_sha256", - .cra_priority = 4001, + .cra_priority = 201, .cra_flags = CRYPTO_ALG_ASYNC | CRYPTO_ALG_ALLOCATES_MEMORY, .cra_blocksize = AES_BLOCK_SIZE, .cra_ctxsize = sizeof(struct qat_alg_aead_ctx), @@ -1311,7 +1311,7 @@ static struct aead_alg qat_aeads[] = { { .base = { .cra_name = "authenc(hmac(sha512),cbc(aes))", .cra_driver_name = "qat_aes_cbc_hmac_sha512", - .cra_priority = 4001, + .cra_priority = 201, .cra_flags = CRYPTO_ALG_ASYNC | CRYPTO_ALG_ALLOCATES_MEMORY, .cra_blocksize = AES_BLOCK_SIZE, .cra_ctxsize = sizeof(struct qat_alg_aead_ctx), @@ -1329,7 +1329,7 @@ static struct aead_alg qat_aeads[] = { { static struct skcipher_alg qat_skciphers[] = { { .base.cra_name = "cbc(aes)", .base.cra_driver_name = "qat_aes_cbc", - .base.cra_priority = 4001, + .base.cra_priority = 201, .base.cra_flags = CRYPTO_ALG_ASYNC | CRYPTO_ALG_ALLOCATES_MEMORY, .base.cra_blocksize = AES_BLOCK_SIZE, .base.cra_ctxsize = sizeof(struct qat_alg_skcipher_ctx), @@ -1347,7 +1347,7 @@ static struct skcipher_alg qat_skciphers }, { .base.cra_name = "ctr(aes)", .base.cra_driver_name = "qat_aes_ctr", - .base.cra_priority = 4001, + .base.cra_priority = 201, .base.cra_flags = CRYPTO_ALG_ASYNC | CRYPTO_ALG_ALLOCATES_MEMORY, .base.cra_blocksize = 1, .base.cra_ctxsize = sizeof(struct qat_alg_skcipher_ctx), @@ -1365,7 +1365,7 @@ static struct skcipher_alg qat_skciphers }, { .base.cra_name = "xts(aes)", .base.cra_driver_name = "qat_aes_xts", - .base.cra_priority = 4001, + .base.cra_priority = 201, .base.cra_flags = CRYPTO_ALG_ASYNC | CRYPTO_ALG_NEED_FALLBACK | CRYPTO_ALG_ALLOCATES_MEMORY, .base.cra_blocksize = AES_BLOCK_SIZE,