RE: [PATCH v2] Drivers: vmbus: Check for channel allocation before looking up relids

From: Dexuan Cui
Date: Fri Feb 17 2023 - 14:00:00 EST


> From: Mohammed Gamal <mgamal@xxxxxxxxxx>
> Sent: Friday, February 17, 2023 1:43 AM
> > > @@ -409,6 +409,10 @@ void vmbus_disconnect(void)
> > > */
> > > struct vmbus_channel *relid2channel(u32 relid)
> > > {
> > > + if (vmbus_connection.channels == NULL) {
> > > + WARN(1, "Requested relid=%u, but channel mapping not
> > > allocated!\n", relid);
> >
> > WARN() may be too noisy. I suggest we use pr_warn() instead.
> >
> Makes sense. Will use pr_warn() instead.

As Vitaly suggested, pr_warn_once() looks better.

> > Can we make the line a little shorter:
> > pr_warn("relid2channel: invalid channel id %u\n", relid);
> >
> I think this message could be a bit misleading. The problem here is
> not that the relid
> is invalid, but that the relid-to-channel mapping hasn't been
> allocated by the second
> kernel yet. An invalid relid could simply be the case where relid >=
> MAX_CHANNEL_RELIDS.
>
> May be something like:
> pr_warn("relid2channel: No channels mapped for relid %d\n, relid");
> would be clearer?

IMO the 'relid' is invalid in the second kernel because the second
kernel has not called vmbus_request_offers() yet, but your new message
is ok to me. I just wanted to avoid a too long line of >80 characters :-)