From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 1562AA0577; Wed, 15 Apr 2020 01:42:41 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 185FE1D410; Wed, 15 Apr 2020 01:42:40 +0200 (CEST) Received: from mail-qv1-f67.google.com (mail-qv1-f67.google.com [209.85.219.67]) by dpdk.org (Postfix) with ESMTP id 2FDB81D16B; Wed, 15 Apr 2020 01:42:38 +0200 (CEST) Received: by mail-qv1-f67.google.com with SMTP id p19so872965qve.0; Tue, 14 Apr 2020 16:42:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=YLoEz55x1U1uvu4XZTXxyrjG6ZHKftAYU68ANTvAfMc=; b=vd/jrz/t9ed3YH3cxknnbDVell6mkuwRE5mCew0ujy7vtL1DfFXphGdxBYht15i5jJ As+HjqeGnBf/Seb96w+YBS7kjRhGGgfZAyEUKtnLKKMuXrYkZRuViVOLngh0Hmz4p5iK FT102MyBDgs6hQQ+3Z8VZ/x0USwgXKFUgxWNWNsJekatSdTo1w0hPy5cx/ISnxx3OZun MCYhab1UAVW6jLsFlQ/RnFrL+OsQ/N1gSxXy0rDr2kHLwN3w0xRSuiOHWvO6QfDyGjC8 QJSurxANNuyIGNQZKRsBjLtMgyT+jG69kH4/6W3hp1f+bPBXQsK4ZmW+mJD4WMw14yoK K/SQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=YLoEz55x1U1uvu4XZTXxyrjG6ZHKftAYU68ANTvAfMc=; b=n2bwFFzXJZNiDBNRTOtKpiJxcC8xWiPF7YaFxgUzGOSkxGr6ajIp5XigztTDTSEnQl wbMFR0s2UlXz56LdDD92ySZZR5AhPE+FAUIaSctn9bheqZhIcolT6zmSh/xzVH7Dppb3 W7FTWM4eSpZ3f/2OE3a/Y/W5pMFT3IeV8tVSMp1F8e31vJl0tifPhR96k7mA8VYVAISH Gj5GM/Mol0InKnqt8L/95HFPaSoyhhcO4uGE+bHdn30DmnPEqVtWdW6bp01A61vEpM9O NslF7SZZqHRfpHiuvJ46qZimFrecmOFq1OBma513dJ/AXoE2KKiwvCMjDP08qDgHX5gZ sxzQ== X-Gm-Message-State: AGi0PuaH/r87D+gUjZ+mzLpfeIJMc1hUeBISUPFEUbzGaQlK6LQAUXWt lyzTVdHl0nXqvjfczy6RTNBqNPK4S71wE63HbnI= X-Google-Smtp-Source: APiQypIJdiZ/Ew2AjgUdzzCZZrjLkcmsXgA81psRZlQiz05mb78AiOJVBp3YYbBwH3DKvAONF6hYxoGv/RJIjxwTA1E= X-Received: by 2002:a0c:ec07:: with SMTP id y7mr2529228qvo.183.1586907757379; Tue, 14 Apr 2020 16:42:37 -0700 (PDT) MIME-Version: 1.0 References: <1586680073-11075-1-git-send-email-xiangxia.m.yue@gmail.com> <20200413210658.2308b86e@hermes.lan> In-Reply-To: From: Tonghao Zhang Date: Wed, 15 Apr 2020 07:42:01 +0800 Message-ID: To: =?UTF-8?Q?Mattias_R=C3=B6nnblom?= Cc: David Marchand , Stephen Hemminger , dpdk-dev , "stable@dpdk.org" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Subject: Re: [dpdk-dev] [PATCH dpdk-dev] rte_random: fix crash when random init X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Tue, Apr 14, 2020 at 11:37 PM Mattias R=C3=B6nnblom wrote: > > On 2020-04-14 15:35, David Marchand wrote: > > On Tue, Apr 14, 2020 at 3:20 PM Mattias R=C3=B6nnblom > > wrote: > >> On 2020-04-14 06:43, Tonghao Zhang wrote: > >>> On Tue, Apr 14, 2020 at 12:07 PM Stephen Hemminger > >>> wrote: > >>>> On Sun, 12 Apr 2020 16:27:53 +0800 > >>>> xiangxia.m.yue@gmail.com wrote: > >>>> > >>>>> From: Tonghao Zhang > >>>>> > >>>>> When rte_rand_init is invoked, and the kernel > >>>>> (kernel version < 3.17) running dpdk does't support > >>>>> *getentropy, at the same time, the cpu does't support > >>>>> rdseed, the rte_rand_init will invoke rte_get_timer_cycles > >>>>> which function will invoke rte_get_hpet_cycles > >>>>> (RTE_LIBEAL_USE_HPET was enabled) while *eal_hpet is not > >>>>> allocated. > >>>>> > >>>>> Fixes: faf8fd252785 ("eal: improve entropy for initial PRNG seed") > >>>>> Fixes: 3f002f069612 ("eal: replace libc-based random generation wit= h LFSR") > >>>>> > >>>>> Cc: stable@dpdk.org > >>>>> > >>>>> Signed-off-by: Tonghao Zhang > >>>> Are you sure this patch won't change current default to use HPET (wh= ich is slower)? > >>> In rte_eal_timer_init (linux/eal_timer.c)=EF=BC=8C it will set > >>> eal_timer_source =3D EAL_TIMER_TSC too. > >>> So after rte_eal_init, eal_timer_source =3D=3D EAL_TIMER_TSC which is= the > >>> default timer source actually. > >>> Then this patch will affect RTE_INIT function which invoke > >>> rte_get_timer_cycles. but hpet is not available yet. > >> > >> Would using rte_rdtsc() directly be an option? > > s/rte_rdtsc/rte_get_tsc_cycles/ > > > > This could work, but I am a bit surprised to see an initialisation in > > a constructor. > > The commitlog that moved rte_srand() from rte_eal_init does not > > explain why it was moved. > > > > > The initialization (i.e. automatic seeding) grew in complexity somewhat, > and with the new rte_random.c file, it felt like it would have a good, > new home. > > > That said, maybe it would have been better to add an initialization > function to the rte_random.h API, and have it called from > rte_eal_init(), to avoid the ordering issues with constructors. If we use that solution we can register a callback which invoked when almost resources are available: http://patches.dpdk.org/patch/68313/ > Yet > another alternative would be to just move the seeding logic. > > --=20 Best regards, Tonghao