On 2020-03-27 17:19, jan.som...@dlr.de wrote:
Von: Sebastian Huber [mailto:sebastian.hu...@embedded-brains.de]
Gesendet: Montag, 23. März 2020 14:20
An: Sommer, Jan; devel@rtems.org
Betreff: Re: AW: [PATCH v3 3/3] i386: Port to RTEMS
-----Ursprüngliche Nachricht-----
Von: devel [mailto:devel-boun...@rtems.org] Im Auftrag von
jan.som...@dlr.de
Gesendet: Montag, 23. März 2020 13:50
An: sebastian.hu...@embedded-brains.de; devel@rtems.org
Betreff: AW: [PATCH v3 3/3] i386: Port to RTEMS
-----Ursprüngliche Nachricht-----
Von: Sebastian Huber [mailto:sebastian.hu...@embedded-brains.de]
Gesendet: Montag, 23. März 2020 10:59
An: Sommer, Jan; devel@rtems.org
Betreff: Re: [PATCH v3 3/3] i386: Port to RTEMS
On 23/03/2020 09:06, Jan Sommer wrote:
@@ -4597,7 +4599,12 @@ iflib_device_register(device_t dev, void *sc,
if_shared_ctx_t sctx, if_ctx_t *ct
/* Set up cpu set. If it fails, use the set of all CPUs. */
if (bus_get_cpus(dev, INTR_CPUS, sizeof(ctx->ifc_cpus), &ctx-
ifc_cpus) != 0) {
device_printf(dev, "Unable to fetch CPU list\n");
+#ifndef __rtems__
CPU_COPY(&all_cpus, &ctx->ifc_cpus);
+#else /* __rtems__ */
+ cpuset_t cpus = {all_cpus};
+ CPU_COPY(&cpus, &ctx->ifc_cpus);
+#endif /* __rtems__ */
}
MPASS(CPU_COUNT(&ctx->ifc_cpus) > 0);
What is the reason for this change?
For RTEMS the all_cpus variable has been replaced in freebsd/sys/sys/smp.h
to " #define all_cpus 1U".
The additional variable is there because CPU_COPY requires an address.
Could you please move the changes in non-x86 specific files to a
separate commit. Especially the <sys/callout.h> is an important header
file used across all architectures.
Ok, problems like this are an indication that you try to use a feature which is
not really supported. I would first try to understand what the purpose of the
ifc_cpus is. Maybe this stuff could be disabled completely.
Ok, I investigated the issue further.
If I understand the RTEMS specific settings in sys/smp.h correctly,
rtems-libbsd always assumes to run on a single core?
Yes, most of the time. There are some exceptions, for example the UMA
and the Epoch Based Reclamation.
ifc_cpus is the map of active CPUs, i.e. for RTEMS it should be 1, and is used
to determine the queue sizes.
It is only initialized once from all_cpus, but with CPU_COPY, which requires an
address as source.
In FreeBSD all_cpus is a variable, for RTEMS it is only a define producing a
compile error.
As far as I see it, we could either use a temporary variable as above or maybe
an int for the all_cpus in sys/smp.h instead of the define.
However the latter would move the assignment to a c-file, thus making it harder
to find. Do you have any other idea?
I would prefer to either support this per CPU stuff properly or disable
it via the preprocessor. I normally remove the CPU members from the
structs to catch all use cases. For example in struct callout:
#ifndef __rtems__
volatile int c_cpu; /* CPU we're scheduled on */
#endif /* __rtems__ */
This tinkering makes it more difficult to figure out what is going on in
one year or so.
_______________________________________________
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel