From owner-freebsd-arch@FreeBSD.ORG Sat Feb 15 00:11:02 2014 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id E1488884; Sat, 15 Feb 2014 00:11:01 +0000 (UTC) Received: from h2.funkthat.com (gate2.funkthat.com [208.87.223.18]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id B33B91566; Sat, 15 Feb 2014 00:11:01 +0000 (UTC) Received: from h2.funkthat.com (localhost [127.0.0.1]) by h2.funkthat.com (8.14.3/8.14.3) with ESMTP id s1F0B0hl017264 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 14 Feb 2014 16:11:00 -0800 (PST) (envelope-from jmg@h2.funkthat.com) Received: (from jmg@localhost) by h2.funkthat.com (8.14.3/8.14.3/Submit) id s1F0B0ZW017263; Fri, 14 Feb 2014 16:11:00 -0800 (PST) (envelope-from jmg) Date: Fri, 14 Feb 2014 16:11:00 -0800 From: John-Mark Gurney To: Andriy Gapon Subject: Re: can the scheduler decide to schedule an interrupted but runnable thread on another CPU core? What are the implications for code? Message-ID: <20140215001100.GS34851@funkthat.com> Mail-Followup-To: Andriy Gapon , Andrey Chernov , John Baldwin , "freebsd-hackers@freebsd.org" , "freebsd-arch@freebsd.org" References: <201402141318.44743.jhb@freebsd.org> <52FE5FBF.3090104@freebsd.org> <201402141410.29325.jhb@freebsd.org> <52FE93E6.6030705@freebsd.org> <52FE9A5E.5050300@freebsd.org> <52FEADC9.2040608@FreeBSD.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <52FEADC9.2040608@FreeBSD.org> User-Agent: Mutt/1.4.2.3i X-Operating-System: FreeBSD 7.2-RELEASE i386 X-PGP-Fingerprint: 54BA 873B 6515 3F10 9E88 9322 9CB1 8F74 6D3F A396 X-Files: The truth is out there X-URL: http://resnet.uoregon.edu/~gurney_j/ X-Resume: http://resnet.uoregon.edu/~gurney_j/resume.html X-TipJar: bitcoin:13Qmb6AeTgQecazTWph4XasEsP7nGRbAPE X-to-the-FBI-CIA-and-NSA: HI! HOW YA DOIN? can i haz chizburger? X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.2.2 (h2.funkthat.com [127.0.0.1]); Fri, 14 Feb 2014 16:11:00 -0800 (PST) Cc: "freebsd-hackers@freebsd.org" , "freebsd-arch@freebsd.org" X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Feb 2014 00:11:02 -0000 Andriy Gapon wrote this message on Sat, Feb 15, 2014 at 01:59 +0200: > on 15/02/2014 00:36 Andrey Chernov said the following: > > On 15.02.2014 2:08, Andrey Chernov wrote: > >> On 14.02.2014 23:10, John Baldwin wrote: > >> > >>>> Due to this bug, not fixed yet, the real picture is more complex: > >>>> http://www.freebsd.org/cgi/query-pr.cgi?pr=kern/163585 > >>> > >>> Eh, that bug report has no useful details, as in, it doesn't list the > >>> actual commands run. If you do 'cpuset -l 6 -s 1' to force all > >>> processes to only use CPU6, then yes, of course the other CPUs are idle > >>> because that's what you _asked_ for. AFAICT, that is all the original > >>> reporter did. At work we regularly add and remove CPUs from the > >>> default set (set 1) on hundreds of machines every day with ULE without > >>> any issues. > >> > >> Probably original report lack certain commands, but I provide the link > >> to the port which reproduces this bug too. All threads there are > >> assigned to the _different_ CPUs and appears as result on single one > >> with SCHED_ULE (not with SCHED_4BSD). And it is what original reporter > >> mean too. It surely happens, maybe not the first time, but on 2nd-3rd. > >> It means that cpuset_setaffinity() is completely broken form SCHED_ULE > >> at least for 3 years. > >> > > > > This is code example from cpuminer port, in case you are interested, it is very simple: > > > > static inline void affine_to_cpu(int id, int cpu) > > { > > cpuset_t set; > > CPU_ZERO(&set); > > CPU_SET(cpu, &set); > > cpuset_setaffinity(CPU_LEVEL_WHICH, CPU_WHICH_CPUSET, -1, sizeof(cpuset_t), &set); > > I think that CPU_WHICH_TID should have been used here. I agree... cpuset(2): The which argument determines how the value of id is interpreted and is of type cpuwhich_t. The which argument may have the following values: CPU_WHICH_TID id is lwpid_t (thread id) CPU_WHICH_PID id is pid_t (process id) CPU_WHICH_CPUSET id is a cpusetid_t (cpuset id) CPU_WHICH_IRQ id is an irq number An id of '-1' may be used with a which of CPU_WHICH_TID, CPU_WHICH_PID, or CPU_WHICH_CPUSET to mean the current thread, process, or current thread's cpuset. All cpuset syscalls allow this usage. -- John-Mark Gurney Voice: +1 415 225 5579 "All that I will do, has been done, All that I have, has not."