Received: by 2002:a25:5b86:0:0:0:0:0 with SMTP id p128csp308442ybb; Thu, 28 Mar 2019 03:02:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqwx5IvMTDoN2ZMtBUijt14qNOvKvQ+Gq9EyvBqpOTfkVwjka7R76X9PiYODFzQPX7gKyH27 X-Received: by 2002:a63:fa01:: with SMTP id y1mr38719520pgh.5.1553767335705; Thu, 28 Mar 2019 03:02:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553767335; cv=none; d=google.com; s=arc-20160816; b=S230syGIEKp1WuyExI2v2Hzm6LvOK5huN5EW2+cTe6LbJVymdtvJ6gOq2vDieVdrC6 mnf+gqIDcC9/IFm8G6Zs6AxVQRXABelcmFHswj91Ex47F59skKzjAZsnFTUKyFINNyDC KKbOuE6g4+eDuwVIM2sp/vMIE4poz/lAc5J/QsHNssfGhq7g6MPByczgGeP7uH4lU0U6 FGCUhQdDZRVLbPTdqGeDeadtXibp2rore05owmcs0LtNwEmPAIQZmAg3/ZDLjdkIeboN JsBrgsjt46Bd30d+zoGmQWEK+xhrTTzBSyV8yDycPwkfiEEnz3Ms557mX1wJSI/YBs09 /GnA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:cc:subject:to :message-id:from:date; bh=TMCS9sCmo4Ta5E827rGIE3svTdaPfQXmWTxUT6Ng9JI=; b=pZLBQbjgXDFxu2Kue9+2hRJe1UoIaSXILMHkmFWIGxobiELiPXOpzHpylyy8AGLt1f 7RybiWX6HgLMok0Gj1xeU7fTyTPQTt++ooJwgfR69I+3qhQKIGKnFtunPIkEOA6mcG8a Mm/FqJ2M0CBqIQvwcRwbaV3QjbtMrJOHrcyDsuYRZ1Sxok35wy6dKAa5rsJabtbRcqTr OG9GMKP5BIVCBZQXZvANGJYwT0wKBnvdG31apxto6MGwO7T0J7lihdWLSgKWDhPezxt1 sidDHGGkOnCy7l2432makm/YvP51WcSTE3yBVLVdXRFJNbovisM5dfgtN/VVOyrlumGk iJoQ== 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 i8si9857862pfd.275.2019.03.28.03.02.00; Thu, 28 Mar 2019 03:02:15 -0700 (PDT) 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 S1727182AbfC1KAt (ORCPT + 99 others); Thu, 28 Mar 2019 06:00:49 -0400 Received: from mx.sdf.org ([205.166.94.20]:62365 "EHLO mx.sdf.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727106AbfC1KAn (ORCPT ); Thu, 28 Mar 2019 06:00:43 -0400 Received: from sdf.org (IDENT:lkml@sdf.lonestar.org [205.166.94.16]) by mx.sdf.org (8.15.2/8.14.5) with ESMTPS id x2SA0RKB000884 (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256 bits) verified NO); Thu, 28 Mar 2019 10:00:28 GMT Received: (from lkml@localhost) by sdf.org (8.15.2/8.12.8/Submit) id x2SA0RcA017002; Thu, 28 Mar 2019 10:00:27 GMT Date: Thu, 28 Mar 2019 10:00:27 GMT From: George Spelvin Message-Id: <201903281000.x2SA0RcA017002@sdf.org> To: linux-kernel@vger.kernel.org, lkml@sdf.org, tytso@mit.edu Subject: Re: [RFC PATCH v2] random: add get_random_max() function Cc: Jason@zx2c4.com In-Reply-To: <201903270655.x2R6tDjo020894@sdf.org> References: <201903241244.x2OCiL8P011277@sdf.org>, <201903270655.x2R6tDjo020894@sdf.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org By the way, I just noticed that my fallback get_random_max64() algorithm (if there's no __int128 type) is completely broken and will need rewriting. It would work if I rejected and regenerated the high half if the low half were out of range, but that's not what it does. The worst case is a range of 0x10000001, where it would return 0x10000000 half the time. Needs rethinking to find something as simple as possible. I'm sure I can come up with something, but I'm not averse to suggestions if anyone has any. (If I had a reliably fast clz/fls, that would open some possibilities, but sigh...)