From owner-svn-src-head@freebsd.org Sun Oct 22 17:37:49 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7A69FE2B97C; Sun, 22 Oct 2017 17:37:49 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: from mail-qt0-x233.google.com (mail-qt0-x233.google.com [IPv6:2607:f8b0:400d:c0d::233]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 3175C6E8C5; Sun, 22 Oct 2017 17:37:49 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: by mail-qt0-x233.google.com with SMTP id k31so23690489qta.6; Sun, 22 Oct 2017 10:37:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=SYe0WYsdU5xCNts6V6zu0Kv9uYtoWGSVtr4vJo4P95w=; b=QsCct3+wPDUDgh6bEZDoetHXTAcmGwHQdQSEGjQOY0ByIBZ4lJRoMH+0Y2Mvhz1+1S ICwvKqNG3jjmerC2w8Vu7sfqzJb+WjheFyFfWLeFwIB8IWYxU6kP8PZ6nGVgJzPBgA+2 dp2N5k1gGF1E6vLdxJTVs+87N6KVlYZCz1eL0YNgx48E6hrqlmblCkpGZojYoupK+LsY PteecO4ugSZyh1ehI32dG1diaL+vtkvIwm0/TPoYXxhN89pWQRMbDSK1Bbqobgn5zAH2 ggngxPhPCMF2QxJVgSDTSYjCXLW+rGcL9hiJOPjgNDEfhxSVVHbGYteReosyIX3aA+TX qTwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=SYe0WYsdU5xCNts6V6zu0Kv9uYtoWGSVtr4vJo4P95w=; b=GjNjMG9fgtyjLXjNUhXNZ3pD7Ygmyfs69O1OgIPfaTcF82F6djaynAeUkTvmPHYDrC PQohNbB7mjdj3ZdGx/Q5Y0CleWh2NyvuR0gcowzdSOefe+GVBdr1jwQF3OfWJWwHumA5 hKm8XKB/P9VvGcEyspuLBTGDRP65LcYMVyY9KCq1ca7vWA9z2rhllGs8rIdExgLRHo9O 0acPD4u8oZrjj0Bqg0TXnLuUjduzfhR7MH4rJwWNH91n23RoPa2mEw1pPj1geiQi8kxU /ij3XXr7iGQfCiSUtmerrifcoDdkqxbCP1YTafBVx6UbMjPk+ToHldVJvLWoA/CRVXyD VkCA== X-Gm-Message-State: AMCzsaUaiH+4zxeLRVpwDCH2LkYDvuBTU9wMC6YF4qfzCcIJI7lGxNA5 +n6ml2dqRZVGHPoMG+5bblDWKv7/KGgqO3zadtE= X-Google-Smtp-Source: ABhQp+R4d5rsNG8s6Gg2LcwmU8pU+a/LB7ttkPIOt5dxDePrbcpl1j7rAlRylw2dvhjAd/GdvskV+6nsvpWSDrSBS8I= X-Received: by 10.200.8.239 with SMTP id y44mr16701399qth.341.1508693867335; Sun, 22 Oct 2017 10:37:47 -0700 (PDT) MIME-Version: 1.0 Received: by 10.237.51.167 with HTTP; Sun, 22 Oct 2017 10:37:46 -0700 (PDT) In-Reply-To: References: <201710221342.v9MDguCC074682@repo.freebsd.org> <316ecd86-a508-fb36-e33c-ba32f5cb8073@selasky.org> From: Mateusz Guzik Date: Sun, 22 Oct 2017 19:37:46 +0200 Message-ID: Subject: Re: svn commit: r324863 - in head/sys: kern sys To: Hans Petter Selasky Cc: Mateusz Guzik , "src-committers@freebsd.org" , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.23 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Sun, 22 Oct 2017 17:37:49 -0000 On Sun, Oct 22, 2017 at 6:59 PM, Hans Petter Selasky wrote: > On 10/22/17 16:50, Mateusz Guzik wrote: > >> On Sun, Oct 22, 2017 at 04:24:41PM +0200, Hans Petter Selasky wrote: >> >>> On 10/22/17 15:42, Mateusz Guzik wrote: >>> >>>> Author: mjg >>>> Date: Sun Oct 22 13:42:56 2017 >>>> New Revision: 324863 >>>> URL: https://svnweb.freebsd.org/changeset/base/324863 >>>> >>>> Log: >>>> Change kdb_active type to u_char. >>>> Fixes warnings from gcc and keeps the small size. Perhaps nesting >>>> >>> should be moved >> >>> to another variablle. >>>> Reported by: ngie >>>> >>>> Modified: >>>> head/sys/kern/subr_kdb.c >>>> head/sys/sys/kdb.h >>>> >>>> Modified: head/sys/kern/subr_kdb.c >>>> >>>> ============================================================ >> ================== >> >>> --- head/sys/kern/subr_kdb.c Sun Oct 22 12:12:52 2017 (r324862) >>>> +++ head/sys/kern/subr_kdb.c Sun Oct 22 13:42:56 2017 (r324863) >>>> @@ -50,7 +50,7 @@ __FBSDID("$FreeBSD$"); >>>> #include >>>> #endif >>>> -bool __read_frequently kdb_active = 0; >>>> +u_char __read_frequently kdb_active = 0; >>>> static void *kdb_jmpbufp = NULL; >>>> struct kdb_dbbe *kdb_dbbe = NULL; >>>> static struct pcb kdb_pcb; >>>> >>>> Modified: head/sys/sys/kdb.h >>>> >>>> ============================================================ >> ================== >> >>> --- head/sys/sys/kdb.h Sun Oct 22 12:12:52 2017 (r324862) >>>> +++ head/sys/sys/kdb.h Sun Oct 22 13:42:56 2017 (r324863) >>>> @@ -59,7 +59,7 @@ struct kdb_dbbe { >>>> }; \ >>>> DATA_SET(kdb_dbbe_set, name##_dbbe) >>>> -extern bool kdb_active; /* Non-zero while in debugger. */ >>>> +extern u_char kdb_active; /* Non-zero while in debugger. */ >>>> extern int debugger_on_panic; /* enter the debugger on panic. >>>> >>> */ >> >>> extern struct kdb_dbbe *kdb_dbbe; /* Default debugger backend or >>>> >>> NULL. */ >> >>> extern struct trapframe *kdb_frame; /* Frame to kdb_trap(). */ >>>> >>>> >>>> >>> Should we add __aligned(8) to this definition? >>> >>> ./systm.h:#define __read_frequently >>> >> __section(".data.read_frequently") >> >>> >>> It will prevent commonly read variables from residing in two different >>> cache-lines on x86 and amd64 at least??? >>> >>> >> I don't follow. This would *increase* alignemnt requirement and in >> particular prevent bool variables from being put in consecutive bytes. >> >> To answer the question from your other e-mail, the bigger the type the >> worse it is as it takes more space. The idea is to change all frequently >> read and effectively bool variables from int to bool so that more of >> them fit in one cacheline. >> >> Right now there is nothing to nicely sort them to get rid of holes, but >> I'm tinkering with automagic size addition to section name. >> >> > Hi, > > The point is that for x86 there is no alignment so the variables get > packed back to back, and then you sometimes get not so smart layouts, like > that an integer crosses a cache line. > > They are aligned to their size and this creates holes, like here: ffffffff8112873c D kdb_active ---------------- ffffffff81128740 D audit_enabled Regarding automation: Maybe the idea behind sysinit can be used: > sys/boot/usb/tools/sysinit.c > I don't know how this can be plugged here. Would this require defining variables elsewhere? Preferably they would be sorted by the linker. -- Mateusz Guzik