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 X-Spam-Level: X-Spam-Status: No, score=-2.3 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 66AF3C5DF60 for ; Fri, 8 Nov 2019 07:41:24 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 355E92178F for ; Fri, 8 Nov 2019 07:41:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Rybu0LVV"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=ti.com header.i=@ti.com header.b="QLHM/T7Q" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 355E92178F Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=ti.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender:Content-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date:Message-ID:From: References:To:Subject:Reply-To:Cc:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=wmavsyiQ1NpcOL6tD0ZNSBkdwqWUh9hI4jTV+zt6WOo=; b=Rybu0LVVlIPGsg3q86kd6ncMB CfL6HGJ3J94PJICtgcert7OsqL61dPrCwBnlsW/LBPSctuHUhyG+XI3fxr1uKqs68LA7AuLKZ6OQn 5FK8LdarhruNhw8z7sfWxWIlksJKKUAmkArcNtIqiWAabehSPlkdpFkY+/6NFpHCyxu4Si0FIQRtZ xsWpFxQv7Q+9SjGra8jbvcGi9l7ck92AnADQppW+QyNm4JushFIbvsGUUfEEvi26NTWpmKMwuWNH5 ArC1dUltZDDpuL22LzkNwkjKkDpfu4x2Rfga2lcRsDVvu+FXH4HaUGPdkd7+yurf8Ei2HlWUAzNYn 27ME3jhpA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1iSytR-0003xS-AA; Fri, 08 Nov 2019 07:41:17 +0000 Received: from lelv0142.ext.ti.com ([198.47.23.249]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1iSytN-0003wa-M9 for linux-arm-kernel@lists.infradead.org; Fri, 08 Nov 2019 07:41:15 +0000 Received: from fllv0035.itg.ti.com ([10.64.41.0]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id xA87f1JB064030; Fri, 8 Nov 2019 01:41:01 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1573198862; bh=8p57qwOk81qIZzYrBvDYBp3MiSplInyVjuIvJT9EzBE=; h=Subject:To:References:From:Date:In-Reply-To; b=QLHM/T7QV4DXcb4rvpTw7NQ42f4gHZ+sWcPZbWGEAJ36Yb9fE54BOkuE6OfZScEmG qNbRELdBFtcas80D5rWZr5rsu3EIgTqGZU95YmeCU8aQ/CjxXaNSk0ZRi5MmKL2O+v OeGPn2K+u5Bh/z4dI+oL2m5LQ7BTSeCWf4nfeSrc= Received: from DFLE103.ent.ti.com (dfle103.ent.ti.com [10.64.6.24]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTP id xA87f1Cf001150; Fri, 8 Nov 2019 01:41:01 -0600 Received: from DFLE112.ent.ti.com (10.64.6.33) by DFLE103.ent.ti.com (10.64.6.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1847.3; Fri, 8 Nov 2019 01:40:45 -0600 Received: from lelv0326.itg.ti.com (10.180.67.84) by DFLE112.ent.ti.com (10.64.6.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1847.3 via Frontend Transport; Fri, 8 Nov 2019 01:40:45 -0600 Received: from [127.0.0.1] (ileax41-snat.itg.ti.com [10.172.224.153]) by lelv0326.itg.ti.com (8.15.2/8.15.2) with ESMTP id xA87evV2090261; Fri, 8 Nov 2019 01:40:58 -0600 Subject: Re: [PATCH 09/10] crypto: add timeout to crypto_wait_req To: Gilad Ben-Yossef , Herbert Xu , David Miller , Linux Crypto Mailing List , Ard Biesheuvel , , Linux ARM References: <20191017122549.4634-1-t-kristo@ti.com> <20191017122549.4634-10-t-kristo@ti.com> <076f0bc6-ad04-9543-db02-d7c7060db036@ti.com> <20191108022759.GB1140@sol.localdomain> From: Tero Kristo Message-ID: Date: Fri, 8 Nov 2019 09:40:57 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: <20191108022759.GB1140@sol.localdomain> Content-Language: en-US X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191107_234113_873346_57B604D3 X-CRM114-Status: GOOD ( 22.22 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 08/11/2019 04:27, Eric Biggers wrote: > On Wed, Nov 06, 2019 at 09:33:20AM +0200, Gilad Ben-Yossef wrote: >> On Wed, Nov 6, 2019 at 9:25 AM Tero Kristo wrote: >>> >>> On 06/11/2019 08:39, Gilad Ben-Yossef wrote: >>>> Hi, >>>> >>>> >>>> On Thu, Oct 17, 2019 at 3:26 PM Tero Kristo wrote: >>>>> >>>>> Currently crypto_wait_req waits indefinitely for an async crypto request >>>>> to complete. This is bad as it can cause for example the crypto test >>>>> manager to hang without any notification as to why it has happened. >>>>> Instead of waiting indefinitely, add a 1 second timeout to the call, >>>>> and provide a warning print if a timeout happens. >>>> >>>> While the incentive is clear and positive, this suggested solution >>>> creates problems of its own. >>>> In many (most?) cases where we are waiting here, we are waiting for a >>>> DMA operation to finish from hardware. >>>> Exiting while this pending DMA operation is not finished, even with a >>>> proper error return value, is dangerous because >>>> unless the calling code takes great care to not release the memory the >>>> DMA is being done from/to, this can have disastrous effects. >>>> >>>> As Eric has already mentioned, one second might seem like a long time, >>>> but we don't really know if it is enough. >>>> >>>> How about adding a second API (ig. crypto_wait_req_timeout) which >>>> supports a calee specified timeout where >>>> the calle knows how to correctly deal with timeout and port the >>>> relevant call sites to use this? >>> >>> Yeah, that would work for me. I guess we could just swap the testmgr to >>> use this timeout API, as it is quite clear it should timeout rather than >>> wait indefinitely, and afaics, the data buffers it uses are limited >>> size. It doesn't really matter for it whether the timeout is 1 second or >>> 10 seconds, as long as it eventually times out. >> >> >> As long as you avoid releasing the memory used on timeout, that should >> work well, I think. >> > > The memory is always going to be freed eventually, though. Although the crypto > tests currently reuse the input/output buffers and the request structure from > one test to the next, they're freed at the end of the tests. Also, it's unsafe > for one request structure to be used for multiple requests concurrently anyway. > > I think crypto_wait_req_timeout() would just be fundamentally unsafe. > > Couldn't you just use CONFIG_DETECT_HUNG_TASK=y instead? It should report if > any thread is blocked for too long. The problem is not detecting a hung task, the problem is determining what caused the hang. Personally I don't care if the system dies if a crypto accelerator self test has failed, as long as I get reported about the exact nature of the failure. The failures are expected to happen only in development phase of a crypto driver. With the timeout patch in place, I get reported what exact crypto test case failed and I can focus my debug efforts on that one. Anyways, as said this is just a nice to have patch, and can be dropped no issues there. I was just thinking some other people might find it useful also. -Tero -- Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel