Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp773934ybb; Sat, 28 Mar 2020 09:44:39 -0700 (PDT) X-Google-Smtp-Source: ADFU+vt++sQyy5u7MgbgKumE7XBwnM6DvCK6J6BX6AMPdiKclehV3/fCgh37IN4DanD3XVrwttr/ X-Received: by 2002:a05:6830:1541:: with SMTP id l1mr3243344otp.297.1585413879738; Sat, 28 Mar 2020 09:44:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585413879; cv=none; d=google.com; s=arc-20160816; b=EITJ8h2ytWGYJIkTOugC3IBazIz9AtKrt9hcb/wUF2NTNa4N014GTxA4vKnYqpZwZ5 2iY3QuWHLf/0NFv/TFbV2N39J0eNvjkN5umIK+aXNSBuB19uR3GWSX4XoNV+E9oi5z6h xAaXDXcfQccWmJDPZm1/tEiSzsNsz9e87gdoV9hBBRNwmM2XUkhUfjxe9CzEckIj43u6 IAZ4oPlkOqh1MjJxaeLWDwDQ2MwYNcaDGrVslt5+NUZwdYBKQMMvnjdOE8g89S8Ye6kc vpTkFfJlzg0AaUhfOw5La5sQfAB8BpuiXDhzxAot73jPaV50vpyVvnO+lBqsCkR6Mepf PrXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:date:from:message-id; bh=8zgZNIu0mhErk0jfmw4tzwj9T2BLCNF5/jJKHCyOp4Y=; b=QpWLa8TSt7Bh+voHVReVrF0Q7ZQEp67QGNPQbO1S62iXkW/f42RxE1YOb6ZyiDy46L dZtp42z5YqNL2X39JIMT1MeOFAN/E8OL5U+Txq0hGcVBX0XA4HwbOoJhi+GSJrcul9/O EgTzpTnjLyYdPjti/LS8yYsYzTzPp8jUSik9y+zGgw031nAITRRfPSlSlP5/k+xvIEHI B3eV7QEPlr/36ZX9bgQcWoZJdfQ3mFVC8/43t3wO27hI16mKcWcywLwaAgsivzl4vi6S J9o9lHt/Mm/xdJnBVvRw5nQsSCrD8f/6cst6wWylPRHd1+Pfm8A0DeANSZ90SlPzbfky UVDA== 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 x30si4649461otj.27.2020.03.28.09.44.27; Sat, 28 Mar 2020 09:44:39 -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 S1727841AbgC1Qnr (ORCPT + 99 others); Sat, 28 Mar 2020 12:43:47 -0400 Received: from mx.sdf.org ([205.166.94.20]:50065 "EHLO mx.sdf.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727696AbgC1Qna (ORCPT ); Sat, 28 Mar 2020 12:43:30 -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 02SGh7mA016099 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits) verified NO); Sat, 28 Mar 2020 16:43:08 GMT Received: (from lkml@localhost) by sdf.org (8.15.2/8.12.8/Submit) id 02SGh78v026162; Sat, 28 Mar 2020 16:43:07 GMT Message-Id: <202003281643.02SGh78v026162@sdf.org> From: George Spelvin Date: Fri, 29 Nov 2019 17:42:15 -0500 Subject: [RFC PATCH v1 05/50] net/rds/bind.c: Use prandom_u32_max() To: linux-kernel@vger.kernel.org, lkml@sdf.org Cc: Ka-Cheong Poon , Santosh Shilimkar , linux-rdma@vger.kernel.org, rds-devel@oss.oracle.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org max_t(u16, prandom_u32(), 2) generates 2 three times as often as any other value. Operating modulo 65534 improves uniformity. Signed-off-by: George Spelvin Cc: Ka-Cheong Poon Cc: Santosh Shilimkar Cc: linux-rdma@vger.kernel.org Cc: rds-devel@oss.oracle.com --- net/rds/bind.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/rds/bind.c b/net/rds/bind.c index 5b5fb4ca8d3e5..8293044767b83 100644 --- a/net/rds/bind.c +++ b/net/rds/bind.c @@ -104,7 +104,7 @@ static int rds_add_bound(struct rds_sock *rs, const struct in6_addr *addr, return -EINVAL; last = rover; } else { - rover = max_t(u16, prandom_u32(), 2); + rover = 2 + prandom_u32_max(65534); last = rover - 1; } -- 2.26.0