Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753539AbbHVOBM (ORCPT ); Sat, 22 Aug 2015 10:01:12 -0400 Received: from mail-yk0-f174.google.com ([209.85.160.174]:36146 "EHLO mail-yk0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752676AbbHVOBL (ORCPT ); Sat, 22 Aug 2015 10:01:11 -0400 From: William Breathitt Gray X-Enigmail-Draft-Status: N1110 To: linux-kernel@vger.kernel.org Cc: john.stultz@linaro.org, tglx@linutronix.de Subject: Regarding USER_HZ and the exposure of kernel jiffies in userspace Message-ID: <55D880F3.4030909@gmail.com> Date: Sat, 22 Aug 2015 10:02:27 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2743 Lines: 59 Hello, I submitted a bug report a couple months ago regarding the exposure of unscaled kernel jiffies in the /proc/timer_list file (see http://bugzilla.kernel.org/show_bug.cgi?id=99401): > I noticed that the “jiffies” line from the /proc/timer_list file has a > value that is not scaled via the USER_HZ constant. Looking into the > source code of the kernel/time/timer_list.c file, I found lines > 189-190 to be the cause: > > SEQ_printf(m, "jiffies: %Lu\n", > (unsigned long long)jiffies); > > The actual kernel jiffies are printed out directly without scaling. I > was under the impression that all kernel jiffies should be scaled via > USER_HZ -- e.g. through the jiffies_to_clock_t function provided by > include/linux/jiffies.h -- before exposure in userspace. There has been no response since, and the behavior is still present in Linux version 4.1.6, so I suspect my understanding is faulty and the exposure of unscaled kernel jiffies is in fact intentional behavior. I would like to understand why this behavior is intentional, and correct my faulty impression of the design. Here's my understanding so far, please let me know where I go wrong: The Linux kernel used to have HZ set at a constant 100 for all architectures. As additional architecture support was added, the HZ value became variable: e.g. Linux on one machine could have a HZ value of 1000 while Linux on another machine could have a HZ value of 100. This possibility of a variable HZ value caused existing user code, which had hardcoded an expectation of HZ set to 100, to break due to the exposure in userspace of kernel jiffies which may have be based on a HZ value that was not equal to 100. To prevent the chaos that would occur from years of existing user code hardcoding a constant HZ value of 100, a compromise was made: any exposure of kernel jiffies to userspace should be scaled via a new USER_HZ value -- thus preventing existing user code from breaking on machines with a different HZ value, while still allowing the kernel on those machines to have a HZ value different from the historic 100 value. I believe the error in my understanding is the assumption that _all_ instances of kernel jiffies exposure in userspace should be scaled; but it appears that not all instances are. When are kernel jiffies meant to be scaled via USER_HZ, and when are they not? Thanks, William Breathitt Gray -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/