From mboxrd@z Thu Jan 1 00:00:00 1970 From: Radim =?utf-8?B?S3LEjW3DocWZ?= Subject: Re: [PATCH kvm-unit-tests 2/7] lib/x86/smp: introduce on_cpus Date: Wed, 7 Jun 2017 16:48:34 +0200 Message-ID: <20170607144833.GH28750@potion> References: <20170601154819.18831-1-drjones@redhat.com> <20170601154819.18831-3-drjones@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: kvm@vger.kernel.org, pbonzini@redhat.com To: Andrew Jones Return-path: Received: from mx1.redhat.com ([209.132.183.28]:60752 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751523AbdFGOsh (ORCPT ); Wed, 7 Jun 2017 10:48:37 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DF4033DBEB for ; Wed, 7 Jun 2017 14:48:36 +0000 (UTC) Content-Disposition: inline In-Reply-To: <20170601154819.18831-3-drjones@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: 2017-06-01 17:48+0200, Andrew Jones: > Signed-off-by: Andrew Jones > --- > diff --git a/lib/x86/smp.c b/lib/x86/smp.c > @@ -1,5 +1,6 @@ > @@ -91,6 +95,21 @@ void on_cpu_async(int cpu, void (*function)(void *data), void *data) > __on_cpu(cpu, function, data, 0); > } > (I'm sorry the review took so long.) > +void on_cpus(void (*func)(void)) > +{ > + int cpu; > + > + for (cpu = cpu_count() - 1; cpu >= 0; --cpu) > + on_cpu_async(cpu, (ipi_function_type)func, NULL); Calling a casted function pointer is undefined behavior in C and I think that keeping the argument is better anyway -- the API is consistent that way and you don't need to introduce a global in some patches. > + > + while (cpus_active()) > + ; Add a pause() here, Thanks.