From owner-freebsd-hackers@FreeBSD.ORG Sat Feb 15 02:30:42 2014 Return-Path: Delivered-To: freebsd-hackers@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 DE20C825 for ; Sat, 15 Feb 2014 02:30:41 +0000 (UTC) Received: from mail-la0-f54.google.com (mail-la0-f54.google.com [209.85.215.54]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 579E81DAA for ; Sat, 15 Feb 2014 02:30:40 +0000 (UTC) Received: by mail-la0-f54.google.com with SMTP id y1so9732056lam.41 for ; Fri, 14 Feb 2014 18:30:39 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :subject:references:in-reply-to:content-type :content-transfer-encoding; bh=mxuMC739luJjPFi9wwM5jy8RiUDPXezylsHk+FHZ3rI=; b=KMF6I1hKa44UUVCzrUiJfpHmb41SmGZ23vOTQggeMwhz98PK3oFvs0WU57hMQgSvmN 1KsELRQ5jZbT2E79+aLmmUG3/r7GNV1+J+m99CCTV42G4Y8q1z7J2KwOJ5e8A663vwiL WJVn87Ja5NbivbBbSItw0CTYkGVev3f5hgQtk6SrZVLwmHkmyJUJwPh0hnrLjNNpyqvV MScqXMzvtcLiO+wi+Fyg1PnpNY5TyDVJTgOG+tgDSUc+FDJOUOo5OQ/HqZYaTkchNLEz 0V1zzy8SpYEb/OftseqRMO2BERCcKhJuxNZPaRvqdsnlm3/vTqNycLf0q47HQmlM+Z1s TBbA== X-Gm-Message-State: ALoCoQki7SXEatY20LEtyGVjdC+G9jXsa+WsuM77UYsCpo1Bg3EVjfM/7zTU8IAfU4V7r3+Rfgbh X-Received: by 10.152.201.197 with SMTP id kc5mr14074lac.77.1392431439118; Fri, 14 Feb 2014 18:30:39 -0800 (PST) Received: from [192.168.1.2] ([89.169.173.68]) by mx.google.com with ESMTPSA id w2sm11141662lad.4.2014.02.14.18.30.38 for (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 14 Feb 2014 18:30:38 -0800 (PST) Message-ID: <52FED14E.50304@freebsd.org> Date: Sat, 15 Feb 2014 06:30:38 +0400 From: Andrey Chernov User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.3.0 MIME-Version: 1.0 To: Andriy Gapon , John Baldwin , "freebsd-hackers@freebsd.org" , "freebsd-arch@freebsd.org" Subject: Re: can the scheduler decide to schedule an interrupted but runnable thread on another CPU core? What are the implications for code? 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> <20140215001100.GS34851@funkthat.com> In-Reply-To: <20140215001100.GS34851@funkthat.com> X-Enigmail-Version: 1.7a1pre Content-Type: text/plain; charset=KOI8-R Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Feb 2014 02:30:42 -0000 On 15.02.2014 4:11, John-Mark Gurney wrote: >>> 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. The question still remains: why SCHED_ULE and SCHED_4BSD do different things here on CPU_WHICH_CPUSET == -1 (current thread's cpuset)? It looks like SCHED_ULE changes per/process mask while SCHED_4BSD change per/thread mask in that case. -- http://ache.vniz.net/