LVS
lvs-devel
Google
 
Web LinuxVirtualServer.org

Re: [PATCH net-next] net: ipvs: random start for RR scheduler

To: Menglong Dong <menglong8.dong@xxxxxxxxx>
Subject: Re: [PATCH net-next] net: ipvs: random start for RR scheduler
Cc: Simon Horman <horms@xxxxxxxxxxxx>, Pablo Neira Ayuso <pablo@xxxxxxxxxxxxx>, lvs-devel@xxxxxxxxxxxxxxx, netfilter-devel@xxxxxxxxxxxxxxx, Menglong Dong <imagedong@xxxxxxxxxxx>
From: Julian Anastasov <ja@xxxxxx>
Date: Fri, 13 May 2022 01:23:52 +0300 (EEST)
        Hello,

On Tue, 10 May 2022, Julian Anastasov wrote:

>       What I see is that the value 128 is good but using
> 32 (MAX_STEP in the test) gives good enough results (3% diff).

        Looks like I forgot to add this example how to
reduce code under lock because add/del dest can run in
parallel with scheduling, something that is a drawback
in this solution:

+static void ip_vs_rr_random_start(struct ip_vs_service *svc)
+{
+       struct list_head *old = READ_ONCE(svc->sched_data), *cur = old;
+       u32 start;
+
+       if (!(svc->flags & IP_VS_SVC_F_SCHED_RR_RANDOM) ||
+               svc->num_dests <= 1)   
+               return;
+
+       start = prandom_u32_max(min(svc->num_dests, 32U));
+       while (start--)
+               cur = cur->next;
+       spin_lock_bh(&svc->sched_lock);
+       cmpxchg(&svc->sched_data, old, cur);
+       spin_unlock_bh(&svc->sched_lock);
+}

Regards

--
Julian Anastasov <ja@xxxxxx>


<Prev in Thread] Current Thread [Next in Thread>