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=0.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,MISSING_HEADERS,SPF_PASS,URIBL_BLOCKED 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 8C3B4C4360F for ; Wed, 3 Apr 2019 09:34:30 +0000 (UTC) Received: from shelob.surriel.com (shelob.surriel.com [96.67.55.147]) (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 319B12082C for ; Wed, 3 Apr 2019 09:34:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 319B12082C Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=secunet.com Authentication-Results: mail.kernel.org; spf=fail smtp.mailfrom=kernelnewbies-bounces@kernelnewbies.org Received: from localhost ([::1] helo=shelob.surriel.com) by shelob.surriel.com with esmtp (Exim 4.91) (envelope-from ) id 1hBcHZ-0004uX-Rk; Wed, 03 Apr 2019 05:34:09 -0400 Received: from a.mx.secunet.com ([62.96.220.36]) by shelob.surriel.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.91) (envelope-from ) id 1hBcHX-0004uR-Qm for kernelnewbies@kernelnewbies.org; Wed, 03 Apr 2019 05:34:08 -0400 Received: from localhost (localhost [127.0.0.1]) by a.mx.secunet.com (Postfix) with ESMTP id 8BC6F20185 for ; Wed, 3 Apr 2019 11:34:04 +0200 (CEST) X-Virus-Scanned: by secunet Received: from a.mx.secunet.com ([127.0.0.1]) by localhost (a.mx.secunet.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id d6pwyifgheKU for ; Wed, 3 Apr 2019 11:34:04 +0200 (CEST) Received: from mail-essen-01.secunet.de (mail-essen-01.secunet.de [10.53.40.204]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by a.mx.secunet.com (Postfix) with ESMTPS id 1418B2007E for ; Wed, 3 Apr 2019 11:34:04 +0200 (CEST) Received: from [10.182.7.62] (10.182.7.62) by mail-essen-01.secunet.de (10.53.40.204) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 3 Apr 2019 11:34:03 +0200 CC: References: <20190329200158.GF12004@kroah.com> From: Martin Christian Openpgp: preference=signencrypt Autocrypt: addr=martin.christian@secunet.com; prefer-encrypt=mutual; keydata= xsFNBFpYwm8BEAC0Fxsr95okvqmOU0wYqdmFODEnTKfivkkDJk7iJMATxMGcMqr8X2KBwJO1 meTqAR9LnsB4OTzbznMdLEqDd1JvFQ4a5Da+lMn55yNmPfIYMo6NW5o5VkyVQOqa8iHZuNrv 14uqsrm+Rjl/HRgTu+11xqB1SWXrrKH4wMHArQ1A8FgXTcfrLk/u1gC2fGLt2/EhsU7hjXlt PkTQUAigjV0SYAUya9Ux5elSuq4VBrBgkBuZZi3bvlzIFOQ+IVsxdz0w6JbexPEF8u/AKdLy SuWJCpjo2QLx0t87XCvQCImzyGGJU2UEFkDR9T99pd072e0NvKSwCs9LCciimZEWrXWSbfwo CKsdFsP6JtETYUt/gU8hLhqDL6vawuDxuTI1Ztm5Ij8o9NazJv0BEcgTKc1tv7BPf+kEfSsJ 3GgwRXWtotlX8y/pClhy6XpXk4qglmSLW/Y6QsCK0sd729GMFDtAKzZoRMCZL7+w1YY5ziGm +4YDjPP4Qil3C14OSpjyyHLX+dfyTkR3YzVeT6bvi8JfA6JeEKgh+p9YB/e9TL3d0e86iDg7 fHIMfEk/wc81tRUUnLPwP+UJU7Nmd++LytEme1Ubi0Pt853B3ZAUU/YSRFr/g+OswFy3H0Xo K/22BUzNQkGx3bI3c+eefVvd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LKWyv7RG8MnTM 9Gz/v4WdhbUCr203Fmn8RnGzFbPgTfDKSBe3gLm6QW/JhnJURECLBV3aPmPA3wl2hcozZacj SUYHd/Jhjw1/TKmxZXvD8E99XY5CqV+XchNshryuqF0fq9jQfv0spdSlX88j8Q0W1mPHEqGx 7XZ1NLfDSFwlysJFxJtzhRuxZQ== Subject: Re: Unexpected scheduling with mutexes Message-ID: <8f951fe5-f3bd-367b-e6ac-0ac48c43ec78@secunet.com> Date: Wed, 3 Apr 2019 11:33:56 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <20190329200158.GF12004@kroah.com> X-EXCLAIMER-MD-CONFIG: 2c86f778-e09b-4440-8b15-867914633a10 X-BeenThere: kernelnewbies@kernelnewbies.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Learn about the Linux kernel List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: multipart/mixed; boundary="===============9149591861147418068==" Errors-To: kernelnewbies-bounces@kernelnewbies.org --===============9149591861147418068== Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="s95BJ1LKnBFq7Ie43Nw30niZnNkri1aP1" --s95BJ1LKnBFq7Ie43Nw30niZnNkri1aP1 Content-Type: multipart/mixed; boundary="DS0rohONAMKX4rYiXOb2AiTYiNbzE6ubL"; protected-headers="v1" From: Martin Christian Cc: kernelnewbies@kernelnewbies.org Message-ID: <8f951fe5-f3bd-367b-e6ac-0ac48c43ec78@secunet.com> Subject: Re: Unexpected scheduling with mutexes References: <20190329200158.GF12004@kroah.com> In-Reply-To: <20190329200158.GF12004@kroah.com> --DS0rohONAMKX4rYiXOb2AiTYiNbzE6ubL Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: quoted-printable Thanks a lot for the detailed reply! >> For certain values of `X` there is a significant difference in size >> between the two files, which I don't expect. >> >> A read call to the driver does the following: >> 1. `mutex_lock_interruptible(iolock)` >> 2. `usb_bulk_msg(dev, pipe, buf, X, timeout)` >> 3. `mutex_unlock(iolock)` >> 4. `copy_to_user(buf)` >=20 > What are these values of X that cause differences here? Starting around 1k character device A gets more data until it turns over at around 4K. Request size from 10K yield the expected data rates. Character device A is a "real" random source and returns data much slower than device B, which is a pseudo random source. > But if you are trying to somehow create a real api that you have to > enforce the passing off of writing data from two different character > devices in an interleaved format, you are doing this totally wrong, as > this is not going to work with a simple mutex, as you have found out. As mentioned above, the USB device provides two different streams of random. But the device can process only one request at a time. Also I didn't want to have too much dynamic memory allocation, because I would need to allocate up to 64KB kernel memory on each open. That's because the USB device is designed to provide up to 64K of random in a single "request". A request has a header and footer "protecting" the request as a whole from data confusion. To make things simpler I decided to just allow one user space process at a time for each source - which is enough for our application. But yes, that could probably also got to user space. > So, I really haven't answered your question here except to say, "it's > complicated" and "you aren't measuring what you think you are measuring= " :) Ok, I see. Thanks, Martin Christian --=20 Dipl.-Inf. Martin Christian Senior Berater Entwicklung Hardware secunet Security Networks AG Tel.: +49 201 5454-3612, Fax +49 201 5454-1323 E-Mail: martin.christian@secunet.com Ammonstra=C3=9Fe 74, 01067 Dresden www.secunet.com --DS0rohONAMKX4rYiXOb2AiTYiNbzE6ubL-- --s95BJ1LKnBFq7Ie43Nw30niZnNkri1aP1 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEcVMZ0aBmilTEqb/wI7bvPAzZnFYFAlykfgkACgkQI7bvPAzZ nFZcVBAApqPUtZDBnr181FpLTNDMbw+gzDEtQafBWOCNuH9pzNbpFglnEZAdHOOr mfH9ziXKhcX8M8DHCbMwJgJceneZ1KgvgfeCeL063qHGCmVwGBpo7EvajxViN/N2 9wHaQJtHm1S5n0D3RXn5QN/whqO9rl2/06EqZZIz8+5DSYe3QtkdhDNHZlJcskA2 7j7Uy/dQqqe2XHmu6aa9CDnMcr3988mWxHn/3ATBgDYHw2jToEfD3+/MKpt4FO6C DFvG8tVcKrHMm1dKHjNbtU3775qQisLPtB/sbYpbXgDv9yPUSowrLRe0DPmQqazm xCWnOooGYntdSsM6Ife9EfrNbvt9UC5JFB1gxDifimIBMtVUIMVYRwF0G4AkKzz8 JxKvDAXlPjr3dul84u22qH4sJ5YeTh/GhZHFXykK13PghIx0o5fKCD+i7n9o6CEU aYALxjIQ0UpWLBkKxuzgnIgr13ptvwFHZi0+Ed8KWiJ3OAT3x9eNfTZSYH/GgZQe CdolYdDc/T5n3tJy8lqMEU8CL5qdktUFRfrzYgx5BZ9W+H2mZPDbRlNlegON/jQr bBcS9shvL4qwmPv+57kugq5Cjo8QlihNngDzIRS636pD20pkyh6RpKQR0UbLY8tp KqbEDkuYvZ7aF91tvyw/WpxJUUUUfe7ySfBQInQDor4tw1oo6bs= =R6jQ -----END PGP SIGNATURE----- --s95BJ1LKnBFq7Ie43Nw30niZnNkri1aP1-- --===============9149591861147418068== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies --===============9149591861147418068==--