From nobody Sun Apr 7 04:21:12 2024 X-Original-To: freebsd-hackers@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4VBzZ06y1jz5G7CG for ; Sun, 7 Apr 2024 04:21:28 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [IPv6:2a00:1450:4864:20::632]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1D4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4VBzZ03cFmz4Kjc for ; Sun, 7 Apr 2024 04:21:28 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Authentication-Results: mx1.freebsd.org; none Received: by mail-ej1-x632.google.com with SMTP id a640c23a62f3a-a44665605f3so377859366b.2 for ; Sat, 06 Apr 2024 21:21:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20230601.gappssmtp.com; s=20230601; t=1712463685; x=1713068485; darn=freebsd.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=bd1XU7jJyUI4UCiG9SaTyKJXBirptqiypKKLjQiim08=; b=Vp//2XjiwERot+g4JZ5a0kIGPVR4gKiQ0kCtVKV179n2bvK7d+cAH6W761G9wkWGu7 QUm8ejAQ5XzqkNmawSw0RmDkBlI/7jOCZv8ikur59UAkoOyVP9QuCCq6mm2+1mWOWlYT O/86AJb5nvKkmt9CPH4HVBkkY5azbASPoLH1D86w/J6pbJ6mv2I17Tf1Jt2pdxSDuNUX ooJ3UH87rSEIjqeTqcjm3sfKZJNFPGkHTNM998Y9vW5+YcZ2frXlanR+ntGjxhp1/4I2 12I1BEIBaWBFVI1j3WEJgCT2bnfCICZd1wuj+BGDO2UQLFOJZ23it5yXkA+lFcSiWxkh Z9mA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712463685; x=1713068485; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=bd1XU7jJyUI4UCiG9SaTyKJXBirptqiypKKLjQiim08=; b=hQANAiY1Yvf6hTTX8k3DNGk/P1b4Mkl5nWO+k9Ha/EnqKFtICKxa6qv5t3yLYQHmGA 90Si2P89V72FLh5gZfFsGnwc8wuhQd7dBwhPOUxaqtM0AwDsQ8KTQYbRLhA1QElUTygU jqBiopCDMJ7G9W4NwCHP9vTK4wB+6W+1AQg+d7RhzIF4A9xvPU/yMjT7Fr5XJKVgr/aj nqRh08IHdtJnYmCB4MTx+gaovkMWxfOilyOUCu5tZ2Qr5gLE2k09aXvI9s0wfbTxCvfl LLhHIjeo9p3GGzWu0ugmU6u2IpuQwm+rr6Y8NtdB60GWSbm7juvQUti7dBNI+Gvz3jWH P2VQ== X-Gm-Message-State: AOJu0Yyip2k9L2d82QJ0Ri9MNpVgcTvKq5Rr278Fzyveadpi3Ttvshb5 NCjV77NpOcUTk9dibuIv7LkqK8rxf6m/p1wcfjDZXLZoSaTUGJc1fDG1M7qPAhmqKiFu/OYwkfD 6zW6XQQOsE01X00Bx8/Rkal0XJiERoYYkIl4x1R8Wa++v79E01Us= X-Google-Smtp-Source: AGHT+IE/ldAPWyX70bRzES0EwNol7l2NGRefWtMOEEqvH6dGTjG1Vy8TB3wo2s9//u7Pv6mU7i12xu6dOAhSnl1bs6s= X-Received: by 2002:a17:906:bf47:b0:a51:cc20:9116 with SMTP id ps7-20020a170906bf4700b00a51cc209116mr483982ejb.68.1712463684959; Sat, 06 Apr 2024 21:21:24 -0700 (PDT) List-Id: Technical discussions relating to FreeBSD List-Archive: https://lists.freebsd.org/archives/freebsd-hackers List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-hackers@freebsd.org MIME-Version: 1.0 References: In-Reply-To: From: Warner Losh Date: Sat, 6 Apr 2024 22:21:12 -0600 Message-ID: Subject: Re: Re: Kernel module: return a number from a device To: Rocky Hotas Cc: FreeBSD Hackers Content-Type: multipart/alternative; boundary="000000000000a21afa06157a0538" X-Spamd-Bar: ---- X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:15169, ipnet:2a00:1450::/32, country:US] X-Rspamd-Queue-Id: 4VBzZ03cFmz4Kjc --000000000000a21afa06157a0538 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sat, Apr 6, 2024 at 3:00=E2=80=AFPM Rocky Hotas = wrote: > On apr 06 14:39, Warner Losh wrote: > > When this happens, hit ^t (control t). That will give a traceback of th= e > > call stack which may help you track down where it is hanging (most like= ly > > something is sleeping waiting for an event). > > Thanks! It seems that cat itself is hanging (so, uiomove can still be > the > culprit...): > > $ cat rolld > Opened device "rolld" successfully. > load: 0.44 cmd: cat 13392 [running] 7.67r 1.25u 6.39s 38% 1936k > running means there's a tight loop somewhere... uiomove doesn't do that. It is a bunch of ifs that go to a copyout. Arc4random shouldn't either. I'd add printf to see where. > I also tried to modify rolld_read using only char variables: > > static int > rolld_read(struct cdev *dev __unused, struct uio *uio, int ioflag > __unused) > { > char random_out; > char random_item; > int error; > > random_item =3D (char) arc4random(); > random_out =3D random_item % d_size; > > if ((error =3D uiomove(&random_out, 1, uio)) !=3D 0) > uprintf("uiomove failed!\n"); > > return (error); > } > > > But nothing changed with respect to the first version. > This should produce an infinite number of chars... maybe it is and d_size is 1 and they are all NULs. Try cat -v. Warner > Rocky > > --000000000000a21afa06157a0538 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


On Sat, Apr 6, 2024= at 3:00=E2=80=AFPM Rocky Hotas <rockyhotas@tilde.team> wrote:
On apr 06 14:39, Warne= r Losh wrote:
> When this happens, hit ^t (control t). That will give a traceback of t= he
> call stack which may help you track down where it is hanging (most lik= ely
> something is sleeping waiting for an event).

Thanks! It seems that cat itself is hanging (so, uiomove can still be
the
culprit...):

$ cat rolld
Opened device "rolld" successfully.
load: 0.44=C2=A0 cmd: cat 13392 [running] 7.67r 1.25u 6.39s 38% 1936k

running means there's a tight loop somew= here... uiomove doesn't do that. It is a bunch of ifs that go to a copy= out.=C2=A0 Arc4random shouldn't either. I'd add printf to see where= .


=C2=A0
I also tried to modify rolld_read using only char variables:

static int
rolld_read(struct cdev *dev __unused, struct uio *uio, int ioflag
__unused)
{
=C2=A0 =C2=A0 =C2=A0 =C2=A0 char random_out;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 char random_item;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 int error;

=C2=A0 =C2=A0 =C2=A0 =C2=A0 random_item =3D (char) arc4random();
=C2=A0 =C2=A0 =C2=A0 =C2=A0 random_out =3D random_item % d_size;

=C2=A0 =C2=A0 =C2=A0 =C2=A0 if ((error =3D uiomove(&random_out, 1, uio)= ) !=3D 0)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 uprintf("uiomo= ve failed!\n");

=C2=A0 =C2=A0 =C2=A0 =C2=A0 return (error);
}


But nothing changed with respect to the first version.

This should produce a= n infinite number of chars...=C2=A0 maybe it is and d_size is 1 and they ar= e all NULs. Try cat -v.

= Warner


Rocky

--000000000000a21afa06157a0538--