From owner-svn-src-head@freebsd.org Fri Jun 14 13:46:28 2019 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 48DAF15D043C; Fri, 14 Jun 2019 13:46:28 +0000 (UTC) (envelope-from mavbsd@gmail.com) Received: from mail-yw1-xc32.google.com (mail-yw1-xc32.google.com [IPv6:2607:f8b0:4864:20::c32]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id CCB486BFBE; Fri, 14 Jun 2019 13:46:27 +0000 (UTC) (envelope-from mavbsd@gmail.com) Received: by mail-yw1-xc32.google.com with SMTP id k128so1128932ywf.2; Fri, 14 Jun 2019 06:46:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:to:cc:references:from:openpgp:autocrypt:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=Cz9AULQQIkEWfSLw7ckiL50Vng161AsoGU5KIkEZ2pE=; b=e/Om5VgARnfq5EnYQbYtJykZ104gIOmHogEJC/F5e9hmxXZ+3W1ZS0x+x51CbI1O9M h89NbAyBbg2mgaEEM00Jt8pFWy/crriMJQHXfuABGBfXmwgsBuFZ/QkrCUW6yET7HfU2 BFakGzJfcHiKu82gv+G0RapnZDT06rU1V8iYm38iMEzrX9liQPPJdxv6n4iz1qMWfVv9 S0VIZ1WVYTiMH+9FQ2IPwt0J8Lhz8tbRQ/FPxpMeTN1x/ewGNBRf5zx29aikTcTabqWh Mehyzvtzou+BDAsoigxmuuWGov1G4hqrEUd+kDZ5TZGyEu4jnwWYEpDBfE87Lh5VK4Om b9eg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:to:cc:references:from:openpgp :autocrypt:message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=Cz9AULQQIkEWfSLw7ckiL50Vng161AsoGU5KIkEZ2pE=; b=Cqlq+XrLEk29fFCbTB/jBChG5BrK4K/tHDdlTd4vpAnHd+aCGR1E/wYqqze8+oeTIm H2X/ICMvyoMiTnw4tmdYnhr6/sSrgw3WWhq8rIjbNYAG+1q++QdYWMOpUFNGx2O7WlI1 y2e/+N199c87zp+qLONbIPkQJtyuLDgRmKOoWuZaPCK7TWqkvVzfwpK9DHQXyKXlVlDY MljfYAldqL3OSE2/Q8dUiX7BYqjnFaO5mRWZI+6UEFDBsEkELxgMtrE+GQcJ8BsQ5vrZ m5vkcPJjNdUprn7eRfxBaMTRLH7nLBtauRz+Uti63xVqouCmuyrHelpD+i16rasLW9kJ lrpA== X-Gm-Message-State: APjAAAWUKzwl7WZphezmzkMQBfva0hUgYvMwF0N9zmPd4wDvnvs3+zbb H/ldl9OcBA75/tYhQcQyAeBLntPFvZs= X-Google-Smtp-Source: APXvYqzURJykRZjWZcubkiAHE8rjg3RtRkEJrPWQmZiqM2d9gquHfTgDQYZrtgrJGlkCho6RNHWLUQ== X-Received: by 2002:a81:2fca:: with SMTP id v193mr49508918ywv.296.1560519986798; Fri, 14 Jun 2019 06:46:26 -0700 (PDT) Received: from mavoffice.ixsystems.com ([12.189.233.129]) by smtp.gmail.com with ESMTPSA id r63sm777464ywr.53.2019.06.14.06.46.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 14 Jun 2019 06:46:26 -0700 (PDT) Sender: Alexander Motin Subject: Re: svn commit: r349029 - head/sys/kern To: Bruce Evans Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org References: <201906140109.x5E19Aj9087899@repo.freebsd.org> <20190614214154.I1201@besplex.bde.org> From: Alexander Motin Openpgp: preference=signencrypt Autocrypt: addr=mav@FreeBSD.org; prefer-encrypt=mutual; keydata= xsBNBFOzxAwBCADkPrax0pI2W/ig0CK9nRJJwsHitAGEZ2HZiFEuti+6/4UVxj81yr4ak/4g 9bKUyC7rMEAp/ZHNhd+MFCPAAcHPvtovnfykqE/vuosCS3wlSLloix2iKVLks0CwbLHGAyne 46lTQW74Xl/33c3W1Z6d8jD9gVFT/xaVzZ0U9xdzOmsYAZaAj4ki0tuxO9F7L+ct9grRe7iP g8t9hai7BL4ee3VRwk2JXnKb7UvBiVITKYWKz1jRvZIrjPokgEcCLOSlv7x/1kjuFnj3xWZU 7HSFFT8J93epBbrSSCsYsppIk2fZH41kaaFXsMQfTPH8wkeM6qwrvOh4HiQM08R+9tThABEB AAHNIUFsZXhhbmRlciBNb3RpbiA8bWF2QEZyZWVCU0Qub3JnPsLAlwQTAQoAQQIbAwULCQgH AwUVCgkICwUWAwIBAAIeAQIXgAIZARYhBOmM88TmnMPNDledVYMYw5VbqyJ/BQJZYMKuBQkN McyiAAoJEIMYw5VbqyJ/tuUIAOG3ONOSNYqjK4eTZ1TVh9jdUBAhWk5nhDFnODN49Wj0AbYm 7aIqy8O1hnCDSZG5LttjSAo3UfXJZDKQM0BLb0gpRMBnAYqO6tdolLNqAbPGJBnGoPjsh24y 6KcbDaNnis+lD4GwPXwQM+92wZGhCUFElPV9NciZGVS65TNIgk7X+yEjjhD1MSWKKijZ1r9Z zIt4OzUTxxNOvzdlABZS88nNRdJkatOQJPmFdd1mpP6UzTNCiLUo1pIqOEtJgvVVDYq5WHY6 tciWWYdmZG/tIBexJmv2mV2OLVjXR6ZeKmntVH14H72/wRHJuYHQC+r5SVRcWWayrThsY6jZ Yr4+raTOwE0EU7PEDAEIAOZgWf2cJIu+58IzP2dkXE/urj3tr4OqrB/yHGWUf71Lz6D0Fi6Z AXgDtmcFLGPfMyWuLAvSM+xmoguk7zC4hRBYvQycmIhuqBq1jO1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message-ID: <399ec4d3-6548-1145-4dea-f0b7850f8381@FreeBSD.org> Date: Fri, 14 Jun 2019 09:46:25 -0400 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <20190614214154.I1201@besplex.bde.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: CCB486BFBE X-Spamd-Bar: ------ Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-6.97 / 15.00]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.97)[-0.971,0]; REPLY(-4.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000,0] 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: Fri, 14 Jun 2019 13:46:28 -0000 Hi Bruce, On 14.06.2019 08:58, Bruce Evans wrote: > On Fri, 14 Jun 2019, Alexander Motin wrote: > >> Log: >>  Update td_runtime of running thread on each statclock(). >> >>  Normally td_runtime is updated on context switch, but there are some >> kernel >>  threads that due to high absolute priority may run for many seconds >> without >>  context switches (yes, that is bad, but that is true), which means their >>  td_runtime was not updated all that time, that made them invisible >> for top >>  other then as some general CPU usage. >> >>  MFC after:    1 week >>  Sponsored by:    iXsystems, Inc. > > This and more is supposed to be done in calcru().  It is also necessary to > adjust for the current timeslice. > > I thought that calcru() was fixed, but the fix seems to be only in my > version of FreeBSD-5.2. > > The bug seems to be in fill_kinfo_proc_only().  calcru() should update > td_runtime for all threads in the proc (and sum into rux_rutime), ... > td_runtime is updated in one other place: in rufetchtd(), but this function > has the same bug eas everywhere else -- it only updates the runtimes for > curthread. I think it has very simple reason -- now each CPU measures CPU time in its own time units, since cpu_ticks() are not synchronized and can not be compared between different CPUs, so to update td_runtime of another running thread you would need to switch to that CPU, or somehow else get the value (cache it periodically?). I see in your code you are using binuptime() calls instead of cpu_ticks(). I suppose it fixes many problems, since it is globally synchronous, but there was a reason why cpu_ticks() exists -- it is cheaper on system non-synchronized TSC. May be we could reconsider that, giving up on old platforms, expecting all new one to not have this problem, but for right now I think my patch is good enough to make top sane again, that annoyed me for years. -- Alexander Motin