From owner-svn-src-head@FreeBSD.ORG Sun Nov 2 20:27:41 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id B6EB3CD2; Sun, 2 Nov 2014 20:27:41 +0000 (UTC) Received: from anubis.delphij.net (anubis.delphij.net [64.62.153.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "anubis.delphij.net", Issuer "StartCom Class 1 Primary Intermediate Server CA" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 8F25212; Sun, 2 Nov 2014 20:27:41 +0000 (UTC) Received: from zeta.ixsystems.com (c-24-5-244-32.hsd1.ca.comcast.net [24.5.244.32]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by anubis.delphij.net (Postfix) with ESMTPSA id 9849614A02; Sun, 2 Nov 2014 12:27:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=delphij.net; s=anubis; t=1414960055; x=1414974455; bh=5Mo1FGWqrDfq8NmyvWHzGkTfDoYpHqPFqtCeExJ5NLo=; h=Date:From:Reply-To:To:CC:Subject:References:In-Reply-To; b=Wy0f6T57ly4Bm1LDY8uVyWMV3HVARudpjpvAIHubFEUmZWkoS+FetBCJNGklir/aU dOYBrf8Chb9Lvv4TL85chH6efu4RTSHb5/+xJbbw2BBtJO2pG7W24qWwDuBVYi4/OK AvslbT6FLt89Q98f5MhvR+z6bGM3Y2lPyBzeo12M= Message-ID: <545693B4.8030602@delphij.net> Date: Sun, 02 Nov 2014 12:27:32 -0800 From: Xin Li Reply-To: d@delphij.net Organization: The FreeBSD Project MIME-Version: 1.0 To: Konstantin Belousov , d@delphij.net Subject: Re: svn commit: r273958 - head/sys/dev/random References: <201411020201.sA221unt091493@svn.freebsd.org> <720EB74E-094A-43F3-8B1C-47BC7F6FECC3@grondar.org> <1414934579.17308.248.camel@revolution.hippie.lan> <6FB65828-6A79-4BDE-A9F7-BC472BA538CE@grondar.org> <20141102192057.GB53947@kib.kiev.ua> <29A795E1-19E2-49E4-9653-143D3F6F3F12@grondar.org> <20141102194625.GC53947@kib.kiev.ua> <751CD860-95B9-4F68-AE69-976B42823AD0@grondar.org> <54568E41.8030305@delphij.net> <20141102201331.GE53947@kib.kiev.ua> In-Reply-To: <20141102201331.GE53947@kib.kiev.ua> Content-Type: multipart/mixed; boundary="------------070609020704050205090900" Cc: "svn-src-head@freebsd.org" , "svn-src-all@freebsd.org" , "src-committers@freebsd.org" , Mark R V Murray X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 02 Nov 2014 20:27:41 -0000 This is a multi-part message in MIME format. --------------070609020704050205090900 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512 Hi, Mark, I'd like to propose the attached patch for review. It replaces tsleep's with sx_sleep's, then checks the return value and quit the loop. Cheers, - -- Xin LI https://www.delphij.net/ FreeBSD - The Power to Serve! Live free or die -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0 iQIcBAEBCgAGBQJUVpO0AAoJEJW2GBstM+nsTcoQAKQglUQUKCh4h+flynK+of1J I8pyCJTqkJHsvQu7Lj8Nh4gd6OQM3+XdpEGymA/wB1Q906cNI8ieLwuXCOmCxYhw xs2XJL5cyp1myDqCp3BRrNta8PPSF8gxfnCeU/0LuItrvcNaE3axNb/eu4g3u5s7 NZObx84C03uRoHMz+9qG0qkZbutY/qN8YP3DQ1WvkYom/i4UT2NGa1EgHLYa9Ofu REQ/lADumxqn5Cw6viKym1wI1HrCu00X602jGjivEzn1L7DSfKFJjckyLC2IbbdY Ydy4ejsILJRPFDt6PrcSWkaSBIy585wP90YsFvSK4riyy1i3HUF4pE5wQPPG/ogV ATm4S9GZgr4mM3SHZrcaTDyrm9BEsEizqBs/F3yyuKBqZt0xtTjv+tupCN5AG1LX DnfgLj7pNAW2SIF7lul34/CzisoKB7b5oEpL9YWOh8DvZiEgHMex4nRqTNAt9T8F 7f5bGvcMHfkIOQIUanxlganUW2ZgVaDPYQADjrEsfqD2pTwwK7glN0jXKJ9YStGW kzbjAQil9X/fliVSzPubbO0XTqAtjnPwONBbjw06vlrwZlkHbLOTz0VVZ3cAJcei 4CkCiEQtuFWbD9QVCUe6snztRRTI542dIlWSDPhSxYV3+hrkCgCeJ3fMvTutf7YZ ejIPZ/NOkhddVmvjMHKw =XrYs -----END PGP SIGNATURE----- --------------070609020704050205090900 Content-Type: text/plain; charset=UTF-8; name="random-tsleep.diff" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="random-tsleep.diff" Index: sys/dev/random/random_adaptors.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- sys/dev/random/random_adaptors.c (revision 273982) +++ sys/dev/random/random_adaptors.c (working copy) @@ -217,7 +217,7 @@ random_adaptor_read(struct cdev *dev __unused, str =20 /* (Un)Blocking logic */ error =3D 0; - while (!random_adaptor->ra_seeded()) { + while (!random_adaptor->ra_seeded() && error =3D=3D 0) { if (flags & O_NONBLOCK) { error =3D EWOULDBLOCK; break; @@ -224,7 +224,8 @@ random_adaptor_read(struct cdev *dev __unused, str } =20 /* Sleep instead of going into a spin-frenzy */ - tsleep(&random_adaptor, PUSER | PCATCH, "block", hz/10); + error =3D sx_sleep(&random_adaptor, &random_adaptors_lock, + PUSER | PCATCH, "block", hz/10); =20 /* keep tapping away at the pre-read until we seed/unblock. */ (random_adaptor->ra_read)(NULL, 0); @@ -298,7 +299,7 @@ random_adaptor_write(struct cdev *dev __unused, st =20 random_buf =3D malloc(PAGE_SIZE, M_ENTROPY, M_WAITOK); =20 - while (uio->uio_resid > 0) { + while (uio->uio_resid > 0 && error =3D=3D 0) { c =3D MIN(uio->uio_resid, PAGE_SIZE); error =3D uiomove(random_buf, c, uio); if (error) @@ -306,7 +307,8 @@ random_adaptor_write(struct cdev *dev __unused, st (random_adaptor->ra_write)(random_buf, c); =20 /* Introduce an annoying delay to stop swamping */ - tsleep(&random_adaptor, PUSER | PCATCH, "block", hz/10); + error =3D sx_sleep(&random_adaptor, &random_adaptors_lock, + PUSER | PCATCH, "block", hz/10); } =20 free(random_buf, M_ENTROPY); --------------070609020704050205090900 Content-Type: application/octet-stream; name="random-tsleep.diff.sig" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="random-tsleep.diff.sig" iQIcBAABCgAGBQJUVpO0AAoJEJW2GBstM+nsokkP/R/K43IDwibhgHgp342TFWgeXs1mvcgq Ao17kPtMb5oC5De7+LwQ6iqbK8Mhk3KhPUbO7tK0WaHIcAr8SG9itLKZDB408TIvrVq1e6Oa NpHdYsCZDZAP7KkWQJKnzw0BXuFjIKjJVWBhcXLrlXD+iO4wxwzPCrPDVWqlT3PamROGaoKK K1kS55rIJLNG5dzfMo3nKWBhw7SHo6SsHk6KRAAfUa2Z10LNF0KJZRyhFkjJNY5SdG/Hr7JG GDQHZoLldH+HnYHu3WIgfyNntGYaOv+OhIXHKjTf8bPHJD3LPASFBnculpCQdirXng1iIihZ 1Pzpzg6qGYbxf1G3pB3+5awemz1cEuCP9Jjg2HDgzj2GNWigRlvKztqfuaMuAvlVfrbd6WAJ +nBGkoTIHmGcPFWkz0Jc9vZc8+oxdMdh7L6ltYmEuqI+T7Q+fvpcneSa7q0UQMF5NyEQNW9p 1PW6lXgwjxXZjEACUjS6Vavtdx2G++HWOZ4r9/21Qh4QIoN5khpSz6jbRFPE6jhgauK5RgdT RrbuOXP0IsTNJSnRWrAB5aly30hnyUDLAmO5WZ6ZvzrLggijUYJiy8UHp/4qpsFYTgCity0v mWdK1iajNjfm22ao0hgRdM3npA2pMAUTXgRh8gl9NyG3zdNS/gu1IdbwJ5mD4srFC7rWlV5Y 8tq6 --------------070609020704050205090900--