On Tue, Apr 25, 2017 at 18:02 +0200, Mike Belopuhov wrote:
> Hi,
> 
> Since only leaf queues can have packets assigned to them, H-FSC
> needs a dedicated placeholder root queue.  Right now we conjure
> it up behind the user's back, but userland doesn't really have
> to deal with this and can let kernel take care of it itself.
> 
> If you take a look at what troubles pfctl has to go into to get
> it right and how much code we actually need for it in the kernel,
> it becomes rather clear where this should be done.  This also
> makes it easier to do further queueing modifications.
> 
> Some programs in ports might need adjustments similar to the
> pftop.c hunk below.
> 
> OK?
>

Forgot to mention that hfsc_free robustness has been improved.
We need to make sure that all classes are destroyed, but we can't
destroy a class with existing children before getting rid of them
first. Therefore we must allow for multiple passes to make sure
all entries have been purged.

> 
> @@ -444,21 +446,26 @@ hfsc_alloc(unsigned int idx, void *q)
>  
>  void
>  hfsc_free(unsigned int idx, void *q)
>  {
>       struct hfsc_if *hif = q;
> -     int i;
> +     struct hfsc_class *cl;
> +     int i, restart;
>  
>       KERNEL_ASSERT_LOCKED();
>       KASSERT(idx == 0); /* when hfsc is enabled we only use the first ifq */
>  
>       timeout_del(&hif->hif_defer);
>  
> -     i = hif->hif_allocated;
> -     do
> -             hfsc_class_destroy(hif, hif->hif_class_tbl[--i]);
> -     while (i > 0);
> +     do {
> +             restart = 0;
> +             for (i = 0; i < hif->hif_allocated; i++) {
> +                     cl = hif->hif_class_tbl[i];
> +                     if (hfsc_class_destroy(hif, cl) == EBUSY)
> +                             restart++;
> +             }
> +     } while (restart > 0);
>  
>       free(hif->hif_class_tbl, M_DEVBUF, hif->hif_allocated * sizeof(void *));
>       free(hif, M_DEVBUF, sizeof(*hif));
>  }
>  

Reply via email to