From owner-svn-src-head@freebsd.org Wed Feb 12 11:16:56 2020 Return-Path: Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 1C39A234DC4; Wed, 12 Feb 2020 11:16:56 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 48HcY36zSJz4G18; Wed, 12 Feb 2020 11:16:55 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D11D32036F; Wed, 12 Feb 2020 11:16:55 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 01CBGtYT085994; Wed, 12 Feb 2020 11:16:55 GMT (envelope-from mjg@FreeBSD.org) Received: (from mjg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 01CBGtGe085992; Wed, 12 Feb 2020 11:16:55 GMT (envelope-from mjg@FreeBSD.org) Message-Id: <202002121116.01CBGtGe085992@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mjg set sender to mjg@FreeBSD.org using -f From: Mateusz Guzik Date: Wed, 12 Feb 2020 11:16:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r357808 - in head/sys: kern sys X-SVN-Group: head X-SVN-Commit-Author: mjg X-SVN-Commit-Paths: in head/sys: kern sys X-SVN-Commit-Revision: 357808 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Feb 2020 11:16:56 -0000 Author: mjg Date: Wed Feb 12 11:16:55 2020 New Revision: 357808 URL: https://svnweb.freebsd.org/changeset/base/357808 Log: Add smp_rendezvous_cpus_retry This is a wrapper around smp_rendezvous_cpus which enables use of IPI handlers which can fail and require retrying. wait_func argument is added to to provide a routine which can be used to poll CPU of interest for when the IPI can be retried. Handlers which succeed must call smp_rendezvous_cpus_done to denote that fact. Discussed with: jeff Differential Revision: https://reviews.freebsd.org/D23582 Modified: head/sys/kern/subr_smp.c head/sys/sys/smp.h Modified: head/sys/kern/subr_smp.c ============================================================================== --- head/sys/kern/subr_smp.c Wed Feb 12 11:15:33 2020 (r357807) +++ head/sys/kern/subr_smp.c Wed Feb 12 11:16:55 2020 (r357808) @@ -884,6 +884,47 @@ smp_no_rendezvous_barrier(void *dummy) #endif } +void +smp_rendezvous_cpus_retry(cpuset_t map, + void (* setup_func)(void *), + void (* action_func)(void *), + void (* teardown_func)(void *), + void (* wait_func)(void *, int), + struct smp_rendezvous_cpus_retry_arg *arg) +{ + int cpu; + + /* + * Execute an action on all specified CPUs while retrying until they + * all acknowledge completion. + */ + CPU_COPY(&map, &arg->cpus); + for (;;) { + smp_rendezvous_cpus( + arg->cpus, + setup_func, + action_func, + teardown_func, + arg); + + if (CPU_EMPTY(&arg->cpus)) + break; + + CPU_FOREACH(cpu) { + if (!CPU_ISSET(cpu, &arg->cpus)) + continue; + wait_func(arg, cpu); + } + } +} + +void +smp_rendezvous_cpus_done(struct smp_rendezvous_cpus_retry_arg *arg) +{ + + CPU_CLR_ATOMIC(curcpu, &arg->cpus); +} + /* * Wait for specified idle threads to switch once. This ensures that even * preempted threads have cycled through the switch function once, Modified: head/sys/sys/smp.h ============================================================================== --- head/sys/sys/smp.h Wed Feb 12 11:15:33 2020 (r357807) +++ head/sys/sys/smp.h Wed Feb 12 11:16:55 2020 (r357808) @@ -276,6 +276,19 @@ void smp_rendezvous_cpus(cpuset_t, void (*)(void *), void (*)(void *), void *arg); + +struct smp_rendezvous_cpus_retry_arg { + cpuset_t cpus; +}; +void smp_rendezvous_cpus_retry(cpuset_t, + void (*)(void *), + void (*)(void *), + void (*)(void *), + void (*)(void *, int), + struct smp_rendezvous_cpus_retry_arg *); + +void smp_rendezvous_cpus_done(struct smp_rendezvous_cpus_retry_arg *); + #endif /* !LOCORE */ #endif /* _KERNEL */ #endif /* _SYS_SMP_H_ */