From owner-freebsd-hackers@freebsd.org Sun Aug 12 06:53:56 2018 Return-Path: Delivered-To: freebsd-hackers@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 B458B1066834 for ; Sun, 12 Aug 2018 06:53:56 +0000 (UTC) (envelope-from lists@eitanadler.com) Received: from mail-yw1-xc2b.google.com (mail-yw1-xc2b.google.com [IPv6:2607:f8b0:4864:20::c2b]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 2B2F77BB6E for ; Sun, 12 Aug 2018 06:53:55 +0000 (UTC) (envelope-from lists@eitanadler.com) Received: by mail-yw1-xc2b.google.com with SMTP id 139-v6so11498621ywg.12 for ; Sat, 11 Aug 2018 23:53:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=eitanadler.com; s=0xdeadbeef; h=mime-version:from:date:message-id:subject:to; bh=F86JrBdwFNAo4awdRUPWM676MTtwCc0SKUbYPfCE7jM=; b=l1uN5C3NGOA+JQ5Pc07qoGxxfB9qK5ob73jVaaDUq5PaW0kDCORLNHeBDiQbEu1A4w zLAXkAYw0t8ruDuIp9O1pUoKOAvdne4ItAJ1lcSuYXQfE9qP/4mP9YjsDkricU61sy2j PQXeYjuiyy9Au1kaKJiVZ7GCoWSzjhDsA3EKA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=F86JrBdwFNAo4awdRUPWM676MTtwCc0SKUbYPfCE7jM=; b=MmW+4x2wwseK8KqeQiyPwqZJXmqiDHglmJhzG8g5kKvIEvzb/KQ3nlQYEyfIpkNdBn 3Efz/Xr7JZNZGBPTNHZ7fK/IcCTEPMeu7JJF+QbPBuw9HwhSb/t666KZG8Qwo9YmgezF AGORXW6Zzr/RhASoBZLTZKipRT6lMjbk4iAKtIESwFQEHTCtavre/fgZwiSofWpS1XRA WpaAIrp6KcrC6qvD0wxfBYaApiye7CpIlXkHhGnGUzm2I9hi0GFxFNbfE8Hq+eAAADay 665sHk6eZncNqZ2jEdcIHLE3GJ6aPvmipCNEIUCJqEkqkRnE/J4OXj2ORkxOSKm9wT6e 5MaQ== X-Gm-Message-State: AOUpUlHv/YYq0ArjeL45J7jKNh76Uxommphr8FxuwijBI399NH2xwl15 knv/Z2Z7YpCdokSgwWaqOpbI5LOcefOq7F2SJYL8QYxjiko= X-Google-Smtp-Source: AA+uWPzDWcD93aMiAZQcZFPxLZLRyeE/dGq8kROiSjcHBRkGfkbnH/ipKj8DjmWnlfiI7c0t58GnS8g/oZrsXl0TQOQ= X-Received: by 2002:a25:734e:: with SMTP id o75-v6mr6493186ybc.69.1534056834851; Sat, 11 Aug 2018 23:53:54 -0700 (PDT) MIME-Version: 1.0 From: Eitan Adler Date: Sat, 11 Aug 2018 23:53:28 -0700 Message-ID: Subject: kernel panic - futex_xchgl () at /usr/src/sys/amd64/linux/linux_support.s:47 To: FreeBSD Hackers , freebsd-emulation@freebsd.org Content-Type: text/plain; charset="UTF-8" X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 12 Aug 2018 06:53:56 -0000 I got this panic recently. Figured I'd send it here. [352792] Fatal trap 12: page fault while in kernel mode [352792] cpuid = 20; apic id = 14 [352792] fault virtual address = 0x804010650 [352792] fault code = supervisor write data, protection violation [352792] instruction pointer = 0x20:0xffffffff83c517f3 [352792] stack pointer = 0x28:0xfffffe03387a38b8 [352792] frame pointer = 0x28:0xfffffe03387a3980 [352792] code segment = base 0x0, limit 0xfffff, type 0x1b [352792] = DPL 0, pres 1, long 1, def32 0, gran 1 [352792] processor eflags = interrupt enabled, resume, IOPL = 0 [352792] current process = 1863 (java) __curthread () at ./machine/pcpu.h:230 230 __asm("movq %%gs:%1,%0" : "=r" (td) (kgdb) #0 __curthread () at ./machine/pcpu.h:230 #1 doadump (textdump=0) at /usr/src/sys/kern/kern_shutdown.c:366 #2 0xffffffff80437d4b in db_dump (dummy=, dummy2=, dummy3=, dummy4=) at /usr/src/sys/ddb/db_command.c:574 #3 0xffffffff80437b0d in db_command (last_cmdp=, cmd_table=, dopager=) at /usr/src/sys/ddb/db_command.c:481 #4 0xffffffff804378a4 in db_command_loop () at /usr/src/sys/ddb/db_command.c:534 #5 0xffffffff8043aa8f in db_trap (type=, code=) at /usr/src/sys/ddb/db_main.c:252 #6 0xffffffff80bc1da3 in kdb_trap (type=12, code=0, tf=) at /usr/src/sys/kern/subr_kdb.c:693 #7 0xffffffff810504ff in trap_fatal (frame=0xfffffe03387a37f0, eva=) at /usr/src/sys/amd64/amd64/trap.c:906 #8 0xffffffff81050609 in trap_pfault (frame=0xfffffe03387a37f0, usermode=) at /usr/src/sys/amd64/amd64/trap.c:746 #9 0xffffffff8104fc34 in trap (frame=0xfffffe03387a37f0) at /usr/src/sys/amd64/amd64/trap.c:427 #10 #11 futex_xchgl () at /usr/src/sys/amd64/linux/linux_support.s:47 #12 0xffffffff83c3da84 in futex_atomic_op (td=, encoded_op=, uaddr=) at /usr/src/sys/compat/linux/linux_futex.c:685 #13 linux_sys_futex (td=0xfffff8011aac6000, args=0xfffff8011aac63c0) at /usr/src/sys/compat/linux/linux_futex.c:976 #14 0xffffffff81050ef7 in syscallenter (td=0xfffff8011aac6000) at /usr/src/sys/amd64/amd64/../../kern/subr_syscall.c:135 #15 amd64_syscall (td=0xfffff8011aac6000, traced=0) at /usr/src/sys/amd64/amd64/trap.c:1029 #16 #17 0x0000000800e0c006 in ?? () Backtrace stopped: Cannot access memory at address 0x800d15e58 -- Eitan Adler From owner-freebsd-hackers@freebsd.org Sun Aug 12 07:48:58 2018 Return-Path: Delivered-To: freebsd-hackers@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 75FF61067B4C; Sun, 12 Aug 2018 07:48:58 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E8D607D006; Sun, 12 Aug 2018 07:48:57 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id w7C7mfmu034637 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Sun, 12 Aug 2018 10:48:44 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua w7C7mfmu034637 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id w7C7mfGi034636; Sun, 12 Aug 2018 10:48:41 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Sun, 12 Aug 2018 10:48:40 +0300 From: Konstantin Belousov To: Eitan Adler Cc: FreeBSD Hackers , freebsd-emulation@freebsd.org Subject: Re: kernel panic - futex_xchgl () at /usr/src/sys/amd64/linux/linux_support.s:47 Message-ID: <20180812074840.GG2113@kib.kiev.ua> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on tom.home X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 12 Aug 2018 07:48:58 -0000 On Sat, Aug 11, 2018 at 11:53:28PM -0700, Eitan Adler wrote: > I got this panic recently. Figured I'd send it here. > > [352792] Fatal trap 12: page fault while in kernel mode > [352792] cpuid = 20; apic id = 14 > [352792] fault virtual address = 0x804010650 > [352792] fault code = supervisor write data, protection violation > #11 futex_xchgl () at /usr/src/sys/amd64/linux/linux_support.s:47 Update your kernel to the latest HEAD. From owner-freebsd-hackers@freebsd.org Sun Aug 12 20:33:08 2018 Return-Path: Delivered-To: freebsd-hackers@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 C060B107B74E for ; Sun, 12 Aug 2018 20:33:08 +0000 (UTC) (envelope-from wjw@digiware.nl) Received: from smtp.digiware.nl (smtp.digiware.nl [IPv6:2001:4cb8:90:ffff::3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 58641781F5 for ; Sun, 12 Aug 2018 20:33:08 +0000 (UTC) (envelope-from wjw@digiware.nl) Received: from router.digiware.nl (localhost.digiware.nl [127.0.0.1]) by smtp.digiware.nl (Postfix) with ESMTP id 576027875A; Sun, 12 Aug 2018 22:33:06 +0200 (CEST) X-Virus-Scanned: amavisd-new at digiware.com Received: from smtp.digiware.nl ([127.0.0.1]) by router.digiware.nl (router.digiware.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id U1wHCQ02fVI2; Sun, 12 Aug 2018 22:33:05 +0200 (CEST) Received: from [192.168.11.152] (unknown [192.168.11.152]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.digiware.nl (Postfix) with ESMTPSA id BAB5E78759 for ; Sun, 12 Aug 2018 22:33:05 +0200 (CEST) Subject: Write a version for pthread_get_name_np References: <7fa2b876-9397-da2b-cb29-56badf11b66d@ecoracks.nl> To: FreeBSD Hackers From: Willem Jan Withagen X-Forwarded-Message-Id: <7fa2b876-9397-da2b-cb29-56badf11b66d@ecoracks.nl> Message-ID: <42689feb-9bd4-429b-63d7-b9193123ee47@digiware.nl> Date: Sun, 12 Aug 2018 22:33:06 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <7fa2b876-9397-da2b-cb29-56badf11b66d@ecoracks.nl> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-GB X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 12 Aug 2018 20:33:08 -0000 Hi, For some porting I'm trying to write a pthread_get_name_np(), but I have run into a snag.... Tried some the the procstat code I would come up with: int pthread_get_name_np(pthread_t *thread,                         char *name, size_t len){     struct procstat *procstat;     int pid = getpid();     unsigned int count, i;     struct kinfo_proc *kip, *kipp;     procstat = procstat_open_sysctl();     kip = procstat_getprocs(procstat, KERN_PROC_PID | KERN_PROC_INC_THREAD,             pid, &count);     for (i = 0; i < count; i++) {         kipp = &kip[i];         printf("thread: %ld(0x%lx), %ld(0x%lx)\n", thread, thread, kipp->ki_tid, kipp->ki_tid);         if (thread == kipp->ki_tid) {             kinfo_proc_thread_name(kipp, name, len);         }     }     return 0; } Problem only is that the TID value in what procstat_getprocs returns in ki_tid is nowhere near what pthread_self() returns. But both manual page and the include file describe the value as Thread ID. Only in sys/user.h the type is     lwpid_t ki_tid;                 /* XXXKSE thread id */ What do I need to translate one tid into the other so I can really compare them? Thanx, --WjW From owner-freebsd-hackers@freebsd.org Sun Aug 12 20:58:48 2018 Return-Path: Delivered-To: freebsd-hackers@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 C3272107BD70 for ; Sun, 12 Aug 2018 20:58:48 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 27BF87900C for ; Sun, 12 Aug 2018 20:58:48 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id w7CKwZrn028433 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Sun, 12 Aug 2018 23:58:38 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua w7CKwZrn028433 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id w7CKwZp5028432; Sun, 12 Aug 2018 23:58:35 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Sun, 12 Aug 2018 23:58:35 +0300 From: Konstantin Belousov To: Willem Jan Withagen Cc: FreeBSD Hackers Subject: Re: Write a version for pthread_get_name_np Message-ID: <20180812205835.GB2340@kib.kiev.ua> References: <7fa2b876-9397-da2b-cb29-56badf11b66d@ecoracks.nl> <42689feb-9bd4-429b-63d7-b9193123ee47@digiware.nl> MIME-Version: 1.0 Content-Type: text/plain; charset=koi8-r Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <42689feb-9bd4-429b-63d7-b9193123ee47@digiware.nl> User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on tom.home X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 12 Aug 2018 20:58:48 -0000 On Sun, Aug 12, 2018 at 10:33:06PM +0200, Willem Jan Withagen wrote: > Hi, > > For some porting I'm trying to write a pthread_get_name_np(), but > I have run into a snag.... > Tried some the the procstat code I would come up with: > > int pthread_get_name_np(pthread_t *thread, > ššššššššššššššššššššššš char *name, size_t len){ > ššš struct procstat *procstat; > ššš int pid = getpid(); > ššš unsigned int count, i; > ššš struct kinfo_proc *kip, *kipp; > > ššš procstat = procstat_open_sysctl(); > ššš kip = procstat_getprocs(procstat, KERN_PROC_PID | KERN_PROC_INC_THREAD, > ššššššššššš pid, &count); > ššš for (i = 0; i < count; i++) { > ššš ššš kipp = &kip[i]; > ššš ššš printf("thread: %ld(0x%lx), %ld(0x%lx)\n", thread, thread, > kipp->ki_tid, kipp->ki_tid); > ššš ššš if (thread == kipp->ki_tid) { > ššš ššš ššš kinfo_proc_thread_name(kipp, name, len); > ššš ššš } > ššš } > ššš return 0; > } > > Problem only is that the TID value in what procstat_getprocs returns in > ki_tid is nowhere near > what pthread_self() returns. > But both manual page and the include file describe the value as Thread ID. > Only in sys/user.h the type is > ššš lwpid_t ki_tid;šššššššššššššššš /* XXXKSE thread id */ > > What do I need to translate one tid into the other so I can really > compare them? You need to cast pthread_t * to struct thread *, this is an internal libthr structure which represents the thread in userspace. The structure field tid gives you the tid you want to pass to sysctl. From owner-freebsd-hackers@freebsd.org Sun Aug 12 22:01:12 2018 Return-Path: Delivered-To: freebsd-hackers@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 B9A6C107DD37 for ; Sun, 12 Aug 2018 22:01:12 +0000 (UTC) (envelope-from wjw@digiware.nl) Received: from smtp.digiware.nl (smtp.digiware.nl [IPv6:2001:4cb8:90:ffff::3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 1754E7BA5B for ; Sun, 12 Aug 2018 22:01:12 +0000 (UTC) (envelope-from wjw@digiware.nl) Received: from router.digiware.nl (localhost.digiware.nl [127.0.0.1]) by smtp.digiware.nl (Postfix) with ESMTP id A635578A3E; Mon, 13 Aug 2018 00:01:03 +0200 (CEST) X-Virus-Scanned: amavisd-new at digiware.com Received: from smtp.digiware.nl ([127.0.0.1]) by router.digiware.nl (router.digiware.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id yN2EutlVmQ-O; Mon, 13 Aug 2018 00:01:02 +0200 (CEST) Received: from [192.168.11.152] (unknown [192.168.11.152]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.digiware.nl (Postfix) with ESMTPSA id 16FB178A3B; Mon, 13 Aug 2018 00:01:02 +0200 (CEST) Subject: Re: Write a version for pthread_get_name_np To: Konstantin Belousov Cc: FreeBSD Hackers References: <7fa2b876-9397-da2b-cb29-56badf11b66d@ecoracks.nl> <42689feb-9bd4-429b-63d7-b9193123ee47@digiware.nl> <20180812205835.GB2340@kib.kiev.ua> From: Willem Jan Withagen Message-ID: Date: Mon, 13 Aug 2018 00:01:03 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20180812205835.GB2340@kib.kiev.ua> Content-Type: text/plain; charset=koi8-r; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 8bit X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 12 Aug 2018 22:01:12 -0000 On 12/08/2018 22:58, Konstantin Belousov wrote: > On Sun, Aug 12, 2018 at 10:33:06PM +0200, Willem Jan Withagen wrote: >> Hi, >> >> For some porting I'm trying to write a pthread_get_name_np(), but >> I have run into a snag.... >> Tried some the the procstat code I would come up with: >> >> int pthread_get_name_np(pthread_t *thread, >> ššššššššššššššššššššššš char *name, size_t len){ >> ššš struct procstat *procstat; >> ššš int pid = getpid(); >> ššš unsigned int count, i; >> ššš struct kinfo_proc *kip, *kipp; >> >> ššš procstat = procstat_open_sysctl(); >> ššš kip = procstat_getprocs(procstat, KERN_PROC_PID | KERN_PROC_INC_THREAD, >> ššššššššššš pid, &count); >> ššš for (i = 0; i < count; i++) { >> ššš ššš kipp = &kip[i]; >> ššš ššš printf("thread: %ld(0x%lx), %ld(0x%lx)\n", thread, thread, >> kipp->ki_tid, kipp->ki_tid); >> ššš ššš if (thread == kipp->ki_tid) { >> ššš ššš ššš kinfo_proc_thread_name(kipp, name, len); >> ššš ššš } >> ššš } >> ššš return 0; >> } >> >> Problem only is that the TID value in what procstat_getprocs returns in >> ki_tid is nowhere near >> what pthread_self() returns. >> But both manual page and the include file describe the value as Thread ID. >> Only in sys/user.h the type is >> ššš lwpid_t ki_tid;šššššššššššššššš /* XXXKSE thread id */ >> >> What do I need to translate one tid into the other so I can really >> compare them? > > You need to cast pthread_t * to struct thread *, this is an internal > libthr structure which represents the thread in userspace. The > structure field tid gives you the tid you want to pass to sysctl. mmmm, I'm afraid I'm not quit able to followup on your answer. Trying to find what to include to be able to cast this, I can only find a small bit defined in /usr/src/lib/libthr/thread/thr_private.h. /* * lwpid_t is 32bit but kernel thr API exports tid as long type * to preserve the ABI for M:N model in very early date (r131431). */ #define TID(thread) ((uint32_t) ((thread)->tid)) But that I cannot just "include" that file without a lot of mess, and then still it does not compile. So could you point me to where this private part of struct thread is hidding? Thanx, --WjW From owner-freebsd-hackers@freebsd.org Sun Aug 12 22:57:39 2018 Return-Path: Delivered-To: freebsd-hackers@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 259E410587CF for ; Sun, 12 Aug 2018 22:57:39 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A51997DF46 for ; Sun, 12 Aug 2018 22:57:38 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id w7CMvQF8056376 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 13 Aug 2018 01:57:30 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua w7CMvQF8056376 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id w7CMvQXB056375; Mon, 13 Aug 2018 01:57:26 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Mon, 13 Aug 2018 01:57:26 +0300 From: Konstantin Belousov To: Willem Jan Withagen Cc: FreeBSD Hackers Subject: Re: Write a version for pthread_get_name_np Message-ID: <20180812225726.GC2340@kib.kiev.ua> References: <7fa2b876-9397-da2b-cb29-56badf11b66d@ecoracks.nl> <42689feb-9bd4-429b-63d7-b9193123ee47@digiware.nl> <20180812205835.GB2340@kib.kiev.ua> MIME-Version: 1.0 Content-Type: text/plain; charset=koi8-r Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on tom.home X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 12 Aug 2018 22:57:39 -0000 On Mon, Aug 13, 2018 at 12:01:03AM +0200, Willem Jan Withagen wrote: > On 12/08/2018 22:58, Konstantin Belousov wrote: > > On Sun, Aug 12, 2018 at 10:33:06PM +0200, Willem Jan Withagen wrote: > >> Hi, > >> > >> For some porting I'm trying to write a pthread_get_name_np(), but > >> I have run into a snag.... > >> Tried some the the procstat code I would come up with: > >> > >> int pthread_get_name_np(pthread_t *thread, > >> ššššššššššššššššššššššš char *name, size_t len){ > >> ššš struct procstat *procstat; > >> ššš int pid = getpid(); > >> ššš unsigned int count, i; > >> ššš struct kinfo_proc *kip, *kipp; > >> > >> ššš procstat = procstat_open_sysctl(); > >> ššš kip = procstat_getprocs(procstat, KERN_PROC_PID | KERN_PROC_INC_THREAD, > >> ššššššššššš pid, &count); > >> ššš for (i = 0; i < count; i++) { > >> ššš ššš kipp = &kip[i]; > >> ššš ššš printf("thread: %ld(0x%lx), %ld(0x%lx)\n", thread, thread, > >> kipp->ki_tid, kipp->ki_tid); > >> ššš ššš if (thread == kipp->ki_tid) { > >> ššš ššš ššš kinfo_proc_thread_name(kipp, name, len); > >> ššš ššš } > >> ššš } > >> ššš return 0; > >> } > >> > >> Problem only is that the TID value in what procstat_getprocs returns in > >> ki_tid is nowhere near > >> what pthread_self() returns. > >> But both manual page and the include file describe the value as Thread ID. > >> Only in sys/user.h the type is > >> ššš lwpid_t ki_tid;šššššššššššššššš /* XXXKSE thread id */ > >> > >> What do I need to translate one tid into the other so I can really > >> compare them? > > > > You need to cast pthread_t * to struct thread *, this is an internal > > libthr structure which represents the thread in userspace. The > > structure field tid gives you the tid you want to pass to sysctl. > > mmmm, > > I'm afraid I'm not quit able to followup on your answer. > > Trying to find what to include to be able to cast this, I can only find > a small bit defined in /usr/src/lib/libthr/thread/thr_private.h. > /* > * lwpid_t is 32bit but kernel thr API exports tid as long type > * to preserve the ABI for M:N model in very early date (r131431). > */ > #define TID(thread) ((uint32_t) ((thread)->tid)) > > But that I cannot just "include" that file without a lot of mess, and > then still it does not compile. > > So could you point me to where this private part of struct thread is > hidding? I do not understand your confusion. The thr_private.h header is only for use by libthr, the FreeBSD threading library implementation. The function that you are trying to implement, requires understanding of the libthr internals and can only be implemented as part of libthr. Any other attempt to translate libthr handle for thread into tid needs same access to the struct pthread. From owner-freebsd-hackers@freebsd.org Sun Aug 12 23:36:31 2018 Return-Path: Delivered-To: freebsd-hackers@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 0A7141059C15 for ; Sun, 12 Aug 2018 23:36:31 +0000 (UTC) (envelope-from wjw@digiware.nl) Received: from smtp.digiware.nl (smtp.digiware.nl [176.74.240.9]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 9699C7FCC3 for ; Sun, 12 Aug 2018 23:36:30 +0000 (UTC) (envelope-from wjw@digiware.nl) Received: from router.digiware.nl (localhost.digiware.nl [127.0.0.1]) by smtp.digiware.nl (Postfix) with ESMTP id C5CC26CD5; Mon, 13 Aug 2018 01:36:28 +0200 (CEST) X-Virus-Scanned: amavisd-new at digiware.com Received: from smtp.digiware.nl ([127.0.0.1]) by router.digiware.nl (router.digiware.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id KnemwLSWTLRp; Mon, 13 Aug 2018 01:36:28 +0200 (CEST) Received: from [192.168.11.152] (unknown [192.168.11.152]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.digiware.nl (Postfix) with ESMTPSA id D4DD66CCE; Mon, 13 Aug 2018 01:36:27 +0200 (CEST) Subject: Re: Write a version for pthread_get_name_np To: Konstantin Belousov Cc: FreeBSD Hackers References: <7fa2b876-9397-da2b-cb29-56badf11b66d@ecoracks.nl> <42689feb-9bd4-429b-63d7-b9193123ee47@digiware.nl> <20180812205835.GB2340@kib.kiev.ua> <20180812225726.GC2340@kib.kiev.ua> From: Willem Jan Withagen Message-ID: Date: Mon, 13 Aug 2018 01:36:28 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20180812225726.GC2340@kib.kiev.ua> Content-Type: text/plain; charset=koi8-r; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 8bit X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 12 Aug 2018 23:36:31 -0000 On 13/08/2018 00:57, Konstantin Belousov wrote: > On Mon, Aug 13, 2018 at 12:01:03AM +0200, Willem Jan Withagen wrote: >> On 12/08/2018 22:58, Konstantin Belousov wrote: >>> On Sun, Aug 12, 2018 at 10:33:06PM +0200, Willem Jan Withagen wrote: >>>> Hi, >>>> >>>> For some porting I'm trying to write a pthread_get_name_np(), but >>>> I have run into a snag.... >>>> Tried some the the procstat code I would come up with: >>>> >>>> int pthread_get_name_np(pthread_t *thread, >>>> ššššššššššššššššššššššš char *name, size_t len){ >>>> ššš struct procstat *procstat; >>>> ššš int pid = getpid(); >>>> ššš unsigned int count, i; >>>> ššš struct kinfo_proc *kip, *kipp; >>>> >>>> ššš procstat = procstat_open_sysctl(); >>>> ššš kip = procstat_getprocs(procstat, KERN_PROC_PID | KERN_PROC_INC_THREAD, >>>> ššššššššššš pid, &count); >>>> ššš for (i = 0; i < count; i++) { >>>> ššš ššš kipp = &kip[i]; >>>> ššš ššš printf("thread: %ld(0x%lx), %ld(0x%lx)\n", thread, thread, >>>> kipp->ki_tid, kipp->ki_tid); >>>> ššš ššš if (thread == kipp->ki_tid) { >>>> ššš ššš ššš kinfo_proc_thread_name(kipp, name, len); >>>> ššš ššš } >>>> ššš } >>>> ššš return 0; >>>> } >>>> >>>> Problem only is that the TID value in what procstat_getprocs returns in >>>> ki_tid is nowhere near >>>> what pthread_self() returns. >>>> But both manual page and the include file describe the value as Thread ID. >>>> Only in sys/user.h the type is >>>> ššš lwpid_t ki_tid;šššššššššššššššš /* XXXKSE thread id */ >>>> >>>> What do I need to translate one tid into the other so I can really >>>> compare them? >>> >>> You need to cast pthread_t * to struct thread *, this is an internal >>> libthr structure which represents the thread in userspace. The >>> structure field tid gives you the tid you want to pass to sysctl. >> >> mmmm, >> >> I'm afraid I'm not quit able to followup on your answer. >> >> Trying to find what to include to be able to cast this, I can only find >> a small bit defined in /usr/src/lib/libthr/thread/thr_private.h. >> /* >> * lwpid_t is 32bit but kernel thr API exports tid as long type >> * to preserve the ABI for M:N model in very early date (r131431). >> */ >> #define TID(thread) ((uint32_t) ((thread)->tid)) >> >> But that I cannot just "include" that file without a lot of mess, and >> then still it does not compile. >> >> So could you point me to where this private part of struct thread is >> hidding? > I do not understand your confusion. The thr_private.h header is only > for use by libthr, the FreeBSD threading library implementation. The > function that you are trying to implement, requires understanding of the > libthr internals and can only be implemented as part of libthr. > > Any other attempt to translate libthr handle for thread into tid needs > same access to the struct pthread. Oke, I don't have more knowledge of (p)threads than just how to use it. I was trying to do this as a piece of code in the compat.cc of my ceph port. But trying to reread what you write is boils down to: there is no way to link a value returned by (struct pthread *)pthread_self() to the kd_tid value that can be found in the (struct kinfo_proc *) describing that same thread. And even though (struct thread *) has a field: lwpid_t td_tid; /* (b) Thread ID. */ that field seems to be stuck at value td_tid = 32767 every time I look at it with gdb. So it is a pity that this is not going to work this way. --WjW From owner-freebsd-hackers@freebsd.org Sun Aug 12 23:48:12 2018 Return-Path: Delivered-To: freebsd-hackers@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 74F37105B2DF for ; Sun, 12 Aug 2018 23:48:12 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id DC51C802B5 for ; Sun, 12 Aug 2018 23:48:11 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id w7CNm029068512 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 13 Aug 2018 02:48:03 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua w7CNm029068512 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id w7CNm0VJ068511; Mon, 13 Aug 2018 02:48:00 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Mon, 13 Aug 2018 02:48:00 +0300 From: Konstantin Belousov To: Willem Jan Withagen Cc: FreeBSD Hackers Subject: Re: Write a version for pthread_get_name_np Message-ID: <20180812234800.GD2340@kib.kiev.ua> References: <7fa2b876-9397-da2b-cb29-56badf11b66d@ecoracks.nl> <42689feb-9bd4-429b-63d7-b9193123ee47@digiware.nl> <20180812205835.GB2340@kib.kiev.ua> <20180812225726.GC2340@kib.kiev.ua> MIME-Version: 1.0 Content-Type: text/plain; charset=koi8-r Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on tom.home X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 12 Aug 2018 23:48:12 -0000 On Mon, Aug 13, 2018 at 01:36:28AM +0200, Willem Jan Withagen wrote: > On 13/08/2018 00:57, Konstantin Belousov wrote: > > On Mon, Aug 13, 2018 at 12:01:03AM +0200, Willem Jan Withagen wrote: > >> On 12/08/2018 22:58, Konstantin Belousov wrote: > >>> On Sun, Aug 12, 2018 at 10:33:06PM +0200, Willem Jan Withagen wrote: > >>>> Hi, > >>>> > >>>> For some porting I'm trying to write a pthread_get_name_np(), but > >>>> I have run into a snag.... > >>>> Tried some the the procstat code I would come up with: > >>>> > >>>> int pthread_get_name_np(pthread_t *thread, > >>>> ššššššššššššššššššššššš char *name, size_t len){ > >>>> ššš struct procstat *procstat; > >>>> ššš int pid = getpid(); > >>>> ššš unsigned int count, i; > >>>> ššš struct kinfo_proc *kip, *kipp; > >>>> > >>>> ššš procstat = procstat_open_sysctl(); > >>>> ššš kip = procstat_getprocs(procstat, KERN_PROC_PID | KERN_PROC_INC_THREAD, > >>>> ššššššššššš pid, &count); > >>>> ššš for (i = 0; i < count; i++) { > >>>> ššš ššš kipp = &kip[i]; > >>>> ššš ššš printf("thread: %ld(0x%lx), %ld(0x%lx)\n", thread, thread, > >>>> kipp->ki_tid, kipp->ki_tid); > >>>> ššš ššš if (thread == kipp->ki_tid) { > >>>> ššš ššš ššš kinfo_proc_thread_name(kipp, name, len); > >>>> ššš ššš } > >>>> ššš } > >>>> ššš return 0; > >>>> } > >>>> > >>>> Problem only is that the TID value in what procstat_getprocs returns in > >>>> ki_tid is nowhere near > >>>> what pthread_self() returns. > >>>> But both manual page and the include file describe the value as Thread ID. > >>>> Only in sys/user.h the type is > >>>> ššš lwpid_t ki_tid;šššššššššššššššš /* XXXKSE thread id */ > >>>> > >>>> What do I need to translate one tid into the other so I can really > >>>> compare them? > >>> > >>> You need to cast pthread_t * to struct thread *, this is an internal > >>> libthr structure which represents the thread in userspace. The > >>> structure field tid gives you the tid you want to pass to sysctl. > >> > >> mmmm, > >> > >> I'm afraid I'm not quit able to followup on your answer. > >> > >> Trying to find what to include to be able to cast this, I can only find > >> a small bit defined in /usr/src/lib/libthr/thread/thr_private.h. > >> /* > >> * lwpid_t is 32bit but kernel thr API exports tid as long type > >> * to preserve the ABI for M:N model in very early date (r131431). > >> */ > >> #define TID(thread) ((uint32_t) ((thread)->tid)) > >> > >> But that I cannot just "include" that file without a lot of mess, and > >> then still it does not compile. > >> > >> So could you point me to where this private part of struct thread is > >> hidding? > > I do not understand your confusion. The thr_private.h header is only > > for use by libthr, the FreeBSD threading library implementation. The > > function that you are trying to implement, requires understanding of the > > libthr internals and can only be implemented as part of libthr. > > > > Any other attempt to translate libthr handle for thread into tid needs > > same access to the struct pthread. > > Oke, > > I don't have more knowledge of (p)threads than just how to use it. > I was trying to do this as a piece of code in the compat.cc of my ceph port. > > But trying to reread what you write is boils down to: there is no way to > link a value returned by (struct pthread *)pthread_self() to the kd_tid > value that can be found in the (struct kinfo_proc *) describing that > same thread. No, this is not what I said. I am claiming that this functionality must be implemented in libthr. So if you want this function, it needs to be added to libthr, and it is quite trivial to do. You can code it, or you might provide (draft of the) man page, and I will code it according to the spec. > > And even though (struct thread *) has a field: > lwpid_t td_tid; /* (b) Thread ID. */ > that field seems to be stuck at value td_tid = 32767 every time I look > at it with gdb. > > So it is a pity that this is not going to work this way. > > --WjW > From owner-freebsd-hackers@freebsd.org Sun Aug 12 23:58:03 2018 Return-Path: Delivered-To: freebsd-hackers@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 75DF2105B9B1 for ; Sun, 12 Aug 2018 23:58:03 +0000 (UTC) (envelope-from jmg@gold.funkthat.com) Received: from gold.funkthat.com (gate2.funkthat.com [208.87.223.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "gate2.funkthat.com", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id E6B5F806DA; Sun, 12 Aug 2018 23:58:02 +0000 (UTC) (envelope-from jmg@gold.funkthat.com) Received: from gold.funkthat.com (localhost [127.0.0.1]) by gold.funkthat.com (8.15.2/8.15.2) with ESMTPS id w7CNvspb073569 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Sun, 12 Aug 2018 16:57:54 -0700 (PDT) (envelope-from jmg@gold.funkthat.com) Received: (from jmg@localhost) by gold.funkthat.com (8.15.2/8.15.2/Submit) id w7CNvsVr073568; Sun, 12 Aug 2018 16:57:54 -0700 (PDT) (envelope-from jmg) Date: Sun, 12 Aug 2018 16:57:54 -0700 From: John-Mark Gurney To: Eric McCorkle Cc: Warner Losh , FreeBSD Hackers , Brooks Davis Subject: Re: A few build system questions Message-ID: <20180812235754.GI97145@funkthat.com> Mail-Followup-To: Eric McCorkle , Warner Losh , FreeBSD Hackers , Brooks Davis References: <20180802153357.GA25687@spindle.one-eyed-alien.net> <7f143985-2ebb-210a-e314-0deebd3d9f5b@metricspace.net> <7a14aee9-8205-4fc7-a7a0-a9ed2f33751d@metricspace.net> <9c3f08be-2a76-a726-16b2-c1e6a1aa4aa8@metricspace.net> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="SkvwRMAIpAhPCcCJ" Content-Disposition: inline In-Reply-To: <9c3f08be-2a76-a726-16b2-c1e6a1aa4aa8@metricspace.net> X-Operating-System: FreeBSD 11.0-RELEASE-p7 amd64 X-PGP-Fingerprint: D87A 235F FB71 1F3F 55B7 ED9B D5FF 5A51 C0AC 3D65 X-Files: The truth is out there X-URL: https://www.funkthat.com/ X-Resume: https://www.funkthat.com/~jmg/resume.html X-TipJar: bitcoin:13Qmb6AeTgQecazTWph4XasEsP7nGRbAPE X-to-the-FBI-CIA-and-NSA: HI! HOW YA DOIN? can i haz chizburger? User-Agent: Mutt/1.6.1 (2016-04-27) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.4.3 (gold.funkthat.com [127.0.0.1]); Sun, 12 Aug 2018 16:57:54 -0700 (PDT) X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 12 Aug 2018 23:58:03 -0000 --SkvwRMAIpAhPCcCJ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Eric McCorkle wrote this message on Thu, Aug 02, 2018 at 22:29 -0400: > For future reference, this seems to be more or less what I'm after: >=20 > for f in /etc/trust/root/certs/*.pub.pem; do echo -n "static const char > `basename ${f%%.*}`_data[] =3D {"; openssl x509 -outform DER -in > /etc/trust/root/certs/local.pub.pem | hexdump -v -e '1/1 "0x%02x,"'; > echo "};"; done There's also file2c that does the conversion for you. --=20 John-Mark Gurney Voice: +1 415 225 5579 "All that I will do, has been done, All that I have, has not." --SkvwRMAIpAhPCcCJ Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQJ8BAEBCgBmBQJbcMmAXxSAAAAAAC4AKGlzc3Vlci1mcHJAbm90YXRpb25zLm9w ZW5wZ3AuZmlmdGhob3JzZW1hbi5uZXQ2MEI1RTRGMTNDNzYyMDZDNjEyMDBCNjAy MDVGMEIzM0REMDA2QURBAAoJECBfCzPdAGraPc0P/3332Kicagy/4yxJo3JAt28i GJSMf7cTHZUO2H+bipeaGirmWZbB9kTYwEw03APixAngHqzpCeu4U0SSHRYy/D47 ABe0LHNpxF2RyaTCJd0kvwv3yQLuDTZix0JdDBSFQjIbqil7IYBGv8qNtAS86KXT ucFjdZ0NogPxCFTTcugHcIhAA95fFPpdfuqx+w81//bLUuFlsupWWzWjQPGAw+RE wzXE1MFRfwJelSraQDvrSIwnnXw8W13jecJvKfP/flhxqYSu/Akj7XEwZdJ8V6g+ gfu56fYd/UuXPRYuBucNbVCpa38tvBrlmGHrWAd81R/L0WnnlX+CaLB12htQb9AA mF3c76BSOQ92MdC/4VKegu+zTld9Izysu4fq6HpvRJccqlWAiz1YiEUKEzEd1LA2 ikGaMqg+gjnu4AXqeQNdUjae3OgpQyAceszzl9TrBXKOxMkhMtxXWPX7bfHayA7+ J5x8C20U/qGskxf9KbbwUwRrSzA3xWERZHrBRvnLy8TeU+mRvudw3xpeXwzqLxIC ZoIiUG6UZ65NM6JLjeDT4ZhALgorL70ZjVFlpmyypQkjo59Qr7c534Pf9NUPOSJW UGDx25M+fz1UPbkPEGOwyj9fi39T7dvJtTT4ofVJlhZc09S8/AnOm3kETU2BOw5y OG4vbh3YUkO8suxnzvoG =ekFd -----END PGP SIGNATURE----- --SkvwRMAIpAhPCcCJ-- From owner-freebsd-hackers@freebsd.org Mon Aug 13 00:24:09 2018 Return-Path: Delivered-To: freebsd-hackers@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 CE1EA105C63E for ; Mon, 13 Aug 2018 00:24:09 +0000 (UTC) (envelope-from yuripv@yuripv.net) Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 5CF3A811FC for ; Mon, 13 Aug 2018 00:24:09 +0000 (UTC) (envelope-from yuripv@yuripv.net) Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 8967E21161; Sun, 12 Aug 2018 20:24:08 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Sun, 12 Aug 2018 20:24:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yuripv.net; h=cc :content-type:date:from:in-reply-to:message-id:mime-version :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=KSfyyikK5Fc5Th3kSexCP/Q9y0LpiJH1638FMmQqvlw=; b=VcfCNW7w CREfr8cPg13gYqnX9wRk+kD86s8gOAqG32YxaXOkNkpdo83t052N40iaSIpEVSdn qSnuHITKTKrDb9UgXD1FNRnDME82gl5sCrfl7zcm2BHIdmW5uWaUU3w8U/Z2GEQY 5+5Xb5xawPXBaZxM6n81Jd0LhbEbBCH9k8V1CYdZi9UWW/RGrdV/csFfbCiJIP8k Zf7qy/yEUIC8HM+aboqD2Y4I7Av5pm44827Q87AE5OovkVnpSLocqSA39Yn0/Dzg iuoY09hYkxYOj7l3rub18agX2n+wH0FM2hhDmr7gVaQss4h6kVg1v6WgpPESXf2R 6hxCE489pumn8w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; bh=KSfyyikK5Fc5Th3kSexCP/Q9y0Lpi JH1638FMmQqvlw=; b=wBQ7SRFZdDf3CCv30UUU7EV3wGmQN7vgUnuSt3jmpfKRe /SNzlRyqrQzss43J4+sP93AHOAEXprdYAdRSCW79ndT74g9oWCyZnhvVxZZgmFVk Xv3dXvcAjsgYNTuHVkAoRhqCfjq6Gwi/fesenxOdzqfMVZLrxc9M6rtnZ/Zjk8+e LefjJtSbagBLjF/Pfv/CZCmkqcKUNugQSRjTHWM0MJSonbW2uI5jpUcf3xGlCWsz JR1YHOplSHOp1tyKa/uXfALvF2nJoWFMCE1+AIkNboCqu62uU6XVY9nPlYv5wkI2 VtDe50TvHO35zheNh0Qz4L/g2hEvtqIvKRkmJQWwA== X-ME-Proxy: X-ME-Sender: Received: from [192.168.1.2] (unknown [62.183.125.27]) by mail.messagingengine.com (Postfix) with ESMTPA id 7FF04E454E; Sun, 12 Aug 2018 20:24:06 -0400 (EDT) Subject: Re: Write a version for pthread_get_name_np To: Konstantin Belousov , Willem Jan Withagen Cc: FreeBSD Hackers References: <7fa2b876-9397-da2b-cb29-56badf11b66d@ecoracks.nl> <42689feb-9bd4-429b-63d7-b9193123ee47@digiware.nl> <20180812205835.GB2340@kib.kiev.ua> <20180812225726.GC2340@kib.kiev.ua> <20180812234800.GD2340@kib.kiev.ua> From: Yuri Pankov Message-ID: <34158602-9806-0553-af1c-e8dacbb0ffa0@yuripv.net> Date: Mon, 13 Aug 2018 03:24:03 +0300 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.0 MIME-Version: 1.0 In-Reply-To: <20180812234800.GD2340@kib.kiev.ua> Content-Type: multipart/mixed; boundary="------------1453E18930BCF03D3E4A4C2E" Content-Language: en-US X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 13 Aug 2018 00:24:10 -0000 This is a multi-part message in MIME format. --------------1453E18930BCF03D3E4A4C2E Content-Type: text/plain; charset=koi8-r; format=flowed Content-Transfer-Encoding: 8bit Konstantin Belousov wrote: > On Mon, Aug 13, 2018 at 01:36:28AM +0200, Willem Jan Withagen wrote: >> On 13/08/2018 00:57, Konstantin Belousov wrote: >>> On Mon, Aug 13, 2018 at 12:01:03AM +0200, Willem Jan Withagen wrote: >>>> On 12/08/2018 22:58, Konstantin Belousov wrote: >>>>> On Sun, Aug 12, 2018 at 10:33:06PM +0200, Willem Jan Withagen wrote: >>>>>> Hi, >>>>>> >>>>>> For some porting I'm trying to write a pthread_get_name_np(), but >>>>>> I have run into a snag.... >>>>>> Tried some the the procstat code I would come up with: >>>>>> >>>>>> int pthread_get_name_np(pthread_t *thread, >>>>>> ššššššššššššššššššššššš char *name, size_t len){ >>>>>> ššš struct procstat *procstat; >>>>>> ššš int pid = getpid(); >>>>>> ššš unsigned int count, i; >>>>>> ššš struct kinfo_proc *kip, *kipp; >>>>>> >>>>>> ššš procstat = procstat_open_sysctl(); >>>>>> ššš kip = procstat_getprocs(procstat, KERN_PROC_PID | KERN_PROC_INC_THREAD, >>>>>> ššššššššššš pid, &count); >>>>>> ššš for (i = 0; i < count; i++) { >>>>>> ššš ššš kipp = &kip[i]; >>>>>> ššš ššš printf("thread: %ld(0x%lx), %ld(0x%lx)\n", thread, thread, >>>>>> kipp->ki_tid, kipp->ki_tid); >>>>>> ššš ššš if (thread == kipp->ki_tid) { >>>>>> ššš ššš ššš kinfo_proc_thread_name(kipp, name, len); >>>>>> ššš ššš } >>>>>> ššš } >>>>>> ššš return 0; >>>>>> } >>>>>> >>>>>> Problem only is that the TID value in what procstat_getprocs returns in >>>>>> ki_tid is nowhere near >>>>>> what pthread_self() returns. >>>>>> But both manual page and the include file describe the value as Thread ID. >>>>>> Only in sys/user.h the type is >>>>>> ššš lwpid_t ki_tid;šššššššššššššššš /* XXXKSE thread id */ >>>>>> >>>>>> What do I need to translate one tid into the other so I can really >>>>>> compare them? >>>>> >>>>> You need to cast pthread_t * to struct thread *, this is an internal >>>>> libthr structure which represents the thread in userspace. The >>>>> structure field tid gives you the tid you want to pass to sysctl. >>>> >>>> mmmm, >>>> >>>> I'm afraid I'm not quit able to followup on your answer. >>>> >>>> Trying to find what to include to be able to cast this, I can only find >>>> a small bit defined in /usr/src/lib/libthr/thread/thr_private.h. >>>> /* >>>> * lwpid_t is 32bit but kernel thr API exports tid as long type >>>> * to preserve the ABI for M:N model in very early date (r131431). >>>> */ >>>> #define TID(thread) ((uint32_t) ((thread)->tid)) >>>> >>>> But that I cannot just "include" that file without a lot of mess, and >>>> then still it does not compile. >>>> >>>> So could you point me to where this private part of struct thread is >>>> hidding? >>> I do not understand your confusion. The thr_private.h header is only >>> for use by libthr, the FreeBSD threading library implementation. The >>> function that you are trying to implement, requires understanding of the >>> libthr internals and can only be implemented as part of libthr. >>> >>> Any other attempt to translate libthr handle for thread into tid needs >>> same access to the struct pthread. >> >> Oke, >> >> I don't have more knowledge of (p)threads than just how to use it. >> I was trying to do this as a piece of code in the compat.cc of my ceph port. >> >> But trying to reread what you write is boils down to: there is no way to >> link a value returned by (struct pthread *)pthread_self() to the kd_tid >> value that can be found in the (struct kinfo_proc *) describing that >> same thread. > No, this is not what I said. > > I am claiming that this functionality must be implemented in libthr. > So if you want this function, it needs to be added to libthr, and it is > quite trivial to do. > > You can code it, or you might provide (draft of the) man page, and I > will code it according to the spec. How about the attached patch for man page part? >> And even though (struct thread *) has a field: >> lwpid_t td_tid; /* (b) Thread ID. */ >> that field seems to be stuck at value td_tid = 32767 every time I look >> at it with gdb. >> >> So it is a pity that this is not going to work this way. --------------1453E18930BCF03D3E4A4C2E Content-Type: text/plain; charset=UTF-8; name="pthread.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="pthread.diff" diff --git a/share/man/man3/Makefile b/share/man/man3/Makefile index 6197b0affb4d..ff2cb02827d4 100644 --- a/share/man/man3/Makefile +++ b/share/man/man3/Makefile @@ -334,6 +334,7 @@ PTHREAD_MLINKS+=pthread_rwlock_rdlock.3 pthread_rwlock_tryrdlock.3 PTHREAD_MLINKS+=pthread_rwlock_wrlock.3 pthread_rwlock_trywrlock.3 PTHREAD_MLINKS+=pthread_schedparam.3 pthread_getschedparam.3 \ pthread_schedparam.3 pthread_setschedparam.3 +PTHREAD_MLINKS+=pthread_set_name_np.3 pthread_get_name_np.3 PTHREAD_MLINKS+=pthread_spin_init.3 pthread_spin_destroy.3 \ pthread_spin_lock.3 pthread_spin_trylock.3 \ pthread_spin_lock.3 pthread_spin_unlock.3 diff --git a/share/man/man3/pthread_set_name_np.3 b/share/man/man3/pthread_set_name_np.3 index c8e5cb4f62c0..cb32e52e2baf 100644 --- a/share/man/man3/pthread_set_name_np.3 +++ b/share/man/man3/pthread_set_name_np.3 @@ -24,17 +24,20 @@ .\" .\" $FreeBSD$ .\" -.Dd December 2, 2016 +.Dd August 12, 2018 .Dt PTHREAD_SET_NAME_NP 3 .Os .Sh NAME +.Nm pthread_get_name_np , .Nm pthread_set_name_np -.Nd set the thread name +.Nd set and retrieve the thread name .Sh LIBRARY .Lb libpthread .Sh SYNOPSIS .In pthread_np.h .Ft void +.Fn pthread_get_name_np "pthread_t thread" "char *name" "size_t len" +.Ft void .Fn pthread_set_name_np "pthread_t thread" "const char *name" .Sh DESCRIPTION The @@ -43,11 +46,30 @@ function applies a copy of the given .Fa name to the given .Fa thread . +.Pp +The +.Fn pthread_get_name_np +retrieves the +.Fa name +associated with +.Fa thread . +If +.Fn pthread_set_name_np +was not previously called for +.Fa thread , +the buffer pointed to by +.Fa name +will be empty. .Sh ERRORS -Because of the debugging nature of this function, all errors that may +Because of the debugging nature of these functions, all errors that may appear inside are silently ignored. .Sh SEE ALSO .Xr thr_set_name 2 +.Sh STANDARDS +.Fn pthread_set_name_np +and +.Fn pthread_get_name_np +functions are non-standard extensions. .Sh AUTHORS This manual page was written by .An Alexey Zelkin Aq Mt phantom@FreeBSD.org . --------------1453E18930BCF03D3E4A4C2E-- From owner-freebsd-hackers@freebsd.org Mon Aug 13 08:16:32 2018 Return-Path: Delivered-To: freebsd-hackers@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 275E31069EFB for ; Mon, 13 Aug 2018 08:16:32 +0000 (UTC) (envelope-from wjw@digiware.nl) Received: from smtp.digiware.nl (smtp.digiware.nl [IPv6:2001:4cb8:90:ffff::3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B6E808F8EA for ; Mon, 13 Aug 2018 08:16:31 +0000 (UTC) (envelope-from wjw@digiware.nl) Received: from router.digiware.nl (localhost.digiware.nl [127.0.0.1]) by smtp.digiware.nl (Postfix) with ESMTP id 75B5E802C; Mon, 13 Aug 2018 10:16:29 +0200 (CEST) X-Virus-Scanned: amavisd-new at digiware.com Received: from smtp.digiware.nl ([127.0.0.1]) by router.digiware.nl (router.digiware.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ZJS5wj8dj52m; Mon, 13 Aug 2018 10:16:28 +0200 (CEST) Received: from [192.168.11.152] (unknown [192.168.11.152]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.digiware.nl (Postfix) with ESMTPSA id 7734E8026; Mon, 13 Aug 2018 10:16:28 +0200 (CEST) Subject: Re: Write a version for pthread_get_name_np To: Yuri Pankov , Konstantin Belousov Cc: FreeBSD Hackers References: <7fa2b876-9397-da2b-cb29-56badf11b66d@ecoracks.nl> <42689feb-9bd4-429b-63d7-b9193123ee47@digiware.nl> <20180812205835.GB2340@kib.kiev.ua> <20180812225726.GC2340@kib.kiev.ua> <20180812234800.GD2340@kib.kiev.ua> <34158602-9806-0553-af1c-e8dacbb0ffa0@yuripv.net> From: Willem Jan Withagen Message-ID: Date: Mon, 13 Aug 2018 10:16:30 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <34158602-9806-0553-af1c-e8dacbb0ffa0@yuripv.net> Content-Type: text/plain; charset=koi8-r; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 8bit X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 13 Aug 2018 08:16:32 -0000 On 13/08/2018 02:24, Yuri Pankov wrote: > Konstantin Belousov wrote: >> On Mon, Aug 13, 2018 at 01:36:28AM +0200, Willem Jan Withagen wrote: >>> On 13/08/2018 00:57, Konstantin Belousov wrote: >>>> On Mon, Aug 13, 2018 at 12:01:03AM +0200, Willem Jan Withagen wrote: >>>>> On 12/08/2018 22:58, Konstantin Belousov wrote: >>>>>> On Sun, Aug 12, 2018 at 10:33:06PM +0200, Willem Jan Withagen wrote: >>>>>>> Hi, >>>>>>> >>>>>>> For some porting I'm trying to write a pthread_get_name_np(), but >>>>>>> I have run into a snag.... >>>>>>> Tried some the the procstat code I would come up with: >>>>>>> >>>>>>> int pthread_get_name_np(pthread_t *thread, >>>>>>> ššš ššššššššššššššššššššššš char *name, size_t len){ >>>>>>> ššš ššš struct procstat *procstat; >>>>>>> ššš ššš int pid = getpid(); >>>>>>> ššš ššš unsigned int count, i; >>>>>>> ššš ššš struct kinfo_proc *kip, *kipp; >>>>>>> >>>>>>> ššš ššš procstat = procstat_open_sysctl(); >>>>>>> ššš ššš kip = procstat_getprocs(procstat, KERN_PROC_PID | >>>>>>> KERN_PROC_INC_THREAD, >>>>>>> ššš ššššššššššš pid, &count); >>>>>>> ššš ššš for (i = 0; i < count; i++) { >>>>>>> ššš ššš ššš kipp = &kip[i]; >>>>>>> ššš ššš ššš printf("thread: %ld(0x%lx), %ld(0x%lx)\n", thread, >>>>>>> thread, >>>>>>> kipp->ki_tid, kipp->ki_tid); >>>>>>> ššš ššš ššš if (thread == kipp->ki_tid) { >>>>>>> ššš ššš ššš ššš kinfo_proc_thread_name(kipp, name, len); >>>>>>> ššš ššš ššš } >>>>>>> ššš ššš } >>>>>>> ššš ššš return 0; >>>>>>> } >>>>>>> >>>>>>> Problem only is that the TID value in what procstat_getprocs >>>>>>> returns in >>>>>>> ki_tid is nowhere near >>>>>>> what pthread_self() returns. >>>>>>> But both manual page and the include file describe the value as >>>>>>> Thread ID. >>>>>>> Only in sys/user.h the type is >>>>>>> ššš ššš lwpid_t ki_tid;šššššššššššššššš /* XXXKSE thread id */ >>>>>>> >>>>>>> What do I need to translate one tid into the other so I can really >>>>>>> compare them? >>>>>> >>>>>> You need to cast pthread_t * to struct thread *, this is an internal >>>>>> libthr structure which represents the thread in userspace.š The >>>>>> structure field tid gives you the tid you want to pass to sysctl. >>>>> >>>>> mmmm, >>>>> >>>>> I'm afraid I'm not quit able to followup on your answer. >>>>> >>>>> Trying to find what to include to be able to cast this, I can only >>>>> find >>>>> a small bit defined in /usr/src/lib/libthr/thread/thr_private.h. >>>>> /* >>>>> ššš * lwpid_t is 32bit but kernel thr API exports tid as long type >>>>> ššš * to preserve the ABI for M:N model in very early date (r131431). >>>>> ššš */ >>>>> #define TID(thread)šššš ((uint32_t) ((thread)->tid)) >>>>> >>>>> But that I cannot just "include" that file without a lot of mess, and >>>>> then still it does not compile. >>>>> >>>>> So could you point me to where this private part of struct thread is >>>>> hidding? >>>> I do not understand your confusion. The thr_private.h header is only >>>> for use by libthr, the FreeBSD threading library implementation. The >>>> function that you are trying to implement, requires understanding of >>>> the >>>> libthr internals and can only be implemented as part of libthr. >>>> >>>> Any other attempt to translate libthr handle for thread into tid needs >>>> same access to the struct pthread. >>> >>> Oke, >>> >>> I don't have more knowledge of (p)threads than just how to use it. >>> I was trying to do this as a piece of code in the compat.cc of my >>> ceph port. >>> >>> But trying to reread what you write is boils down to: there is no way to >>> link a value returned by (struct pthread *)pthread_self() to the kd_tid >>> value that can be found in the (struct kinfo_proc *) describing that >>> same thread. >> No, this is not what I said. >> >> I am claiming that this functionality must be implemented in libthr. >> So if you want this function, it needs to be added to libthr, and it is >> quite trivial to do. >> >> You can code it, or you might provide (draft of the) man page, and I >> will code it according to the spec. > > How about the attached patch for man page part? Thanx, I guess that'll work. Although I was following the procstat way and when there was no name set we get a '-'. But if Konstatin is going to write it, it is his prerogative. And I would expect it to be equivalent partner of thr_{set,get}_name as well. But that could be added later in the man page. --WjW From owner-freebsd-hackers@freebsd.org Mon Aug 13 15:05:36 2018 Return-Path: Delivered-To: freebsd-hackers@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 C87BE107520C for ; Mon, 13 Aug 2018 15:05:36 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3CFE17D899 for ; Mon, 13 Aug 2018 15:05:36 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id w7DF5O9G076093 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 13 Aug 2018 18:05:27 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua w7DF5O9G076093 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id w7DF5NhX076089; Mon, 13 Aug 2018 18:05:23 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Mon, 13 Aug 2018 18:05:23 +0300 From: Konstantin Belousov To: Willem Jan Withagen Cc: Yuri Pankov , FreeBSD Hackers Subject: Re: Write a version for pthread_get_name_np Message-ID: <20180813150523.GF2340@kib.kiev.ua> References: <7fa2b876-9397-da2b-cb29-56badf11b66d@ecoracks.nl> <42689feb-9bd4-429b-63d7-b9193123ee47@digiware.nl> <20180812205835.GB2340@kib.kiev.ua> <20180812225726.GC2340@kib.kiev.ua> <20180812234800.GD2340@kib.kiev.ua> <34158602-9806-0553-af1c-e8dacbb0ffa0@yuripv.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on tom.home X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 13 Aug 2018 15:05:36 -0000 On Mon, Aug 13, 2018 at 10:16:30AM +0200, Willem Jan Withagen wrote: > I guess that'll work. > > Although I was following the procstat way and when there was no name set > we get a '-'. But if Konstatin is going to write it, it is his prerogative. > And I would expect it to be equivalent partner of thr_{set,get}_name as > well. But that could be added later in the man page. There is no thr_get_name(2). The implementation is available at https://reviews.freebsd.org/D16702. I do not like void return types for both pthread_get_name_np() and pthread_set_name_np(). From owner-freebsd-hackers@freebsd.org Wed Aug 15 10:25:15 2018 Return-Path: Delivered-To: freebsd-hackers@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 B911E107CC7B for ; Wed, 15 Aug 2018 10:25:15 +0000 (UTC) (envelope-from patrick_dkt@yahoo.com.hk) Received: from sonic307-22.consmr.mail.sg3.yahoo.com (sonic307-22.consmr.mail.sg3.yahoo.com [106.10.241.39]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E5B9983E67 for ; Wed, 15 Aug 2018 10:25:13 +0000 (UTC) (envelope-from patrick_dkt@yahoo.com.hk) X-YMail-OSG: FztN0lcVM1nKHzTeWa7uq34MEbqFKTeR5jYmCYruXsarFeNl6Xw1pk5PKcbY7l6 DJIVAwa2qHOYa0m12.M0OIdvVwqyNPbB5ZRNcpOjysq6PkkwzeI4iUVQrND_Pa4Mr6K6opiMj1e9 8d9DP626oEDTE6oMYdpoEJjeYbgHlKGezJxvzFqQXxfYTaCytmyuIliOE2cjS4AIiyS2.Sji9ESz V2RrFXYrEIahUIzmH692rjhHkYBM0KN.onlRTbFwQ5ZJSAO1I6XeM2pSGR8UlLtYvPyS8ncnxrHs hlgmsqjEgxjGueAMI.Dd6kDng1PudNFmAFaWRM8yLo0V9pt9nPQO3.FDKhVTlHDmBqSoLsx9luWy 99nPwXbt22YG0HXGkMjPDqWhYayIL6RZJ4wE6ZRFq7sbPj9JLvx8LSBs0b3jB8cpmiAq50JPU71M jOq452UwoxSoRoJn328uIULy4lsYA8eXbeRCesw_Tpm9t.Ohg2MDtYN5yxQimQj8bqd4bfIpb59L Y.04P7wWqcE01u7ZhE39Zkpiog4hnYBNFgvE5YX3nQjPsCCkpLcw4.1Olg9KD1w1yl8XfCi1GCou oloPH7iMVixj_Hc.h90BnTRjs0Z9PdFGBGh7apoxQkRMm3RJ6HH08plQgLlXrs1wfVLOavW5rM3l yOBNreFCOIu8W7xopL82AILIXnM1Zu7MfLHbODvL0IoA6DAnJKaoqMwWDP2WPeZrHgj1ui5KSxbn aa7M0dQ5a0Q33TRel38d6c4Q6JHcZC_B.233mFCU_xdK0K6.kcLu_1JDH9aMbA6.T84eFo95z2LK l3EcBwB8cNBEZf0E2LO7mVhRCjtfPZoL81ff9R7raoDVaroLgHexSa093WBpvkFDKGrMLZ6k2yGd QKa8cHuXXkOQOFgs61rLobrq_XRv5KW3f9G1N0B5gnIH4WB960VqHkYJhYqJjrV3HTIJk_g0cmZP SLoe1MW8JEIjmfSmoE_Xvze4BC4BsMI5Q Received: from sonic.gate.mail.ne1.yahoo.com by sonic307.consmr.mail.sg3.yahoo.com with HTTP; Wed, 15 Aug 2018 10:25:03 +0000 Date: Wed, 15 Aug 2018 10:25:00 +0000 (UTC) From: Patrick Dung To: "freebsd-hackers@freebsd.org" Message-ID: <1474457216.7423838.1534328700893@mail.yahoo.com> In-Reply-To: <390738685.5860710.1534084162025@mail.yahoo.com> References: <390738685.5860710.1534084162025.ref@mail.yahoo.com> <390738685.5860710.1534084162025@mail.yahoo.com> Subject: Re: Suggestion on some programs or libraries that could be included in FreeBSD base OS MIME-Version: 1.0 X-Mailer: WebService/1.1.12206 YMailNorrin Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Content-Filtered-By: Mailman/MimeDel 2.1.27 X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 15 Aug 2018 10:25:16 -0000 Hello, I understand that the base system should be keep small. I had some programs or libraries in mind that they may be integrated into the base OS. Let's discuss. 1) SASL and GSSAPI support Sendmail and Heimdal (a Kerberos implementation) are already in base.But since SASL is not in base, these programs do not have SASL support. Looks like the Cryus-SASL license https://github.com/cyrusimap/cyrus-sasl/blob/master/COPYINGis a BSD like license. If SASL is included in base, then it would save time for installing or rebuilding Sendmail / Heimdal from ports for SASL/LDAP (see below) support. 2) LDAP client/library supportThere are several LDAP client library like:a) OpenBSD ldap server/clientb) Mozilla C-SDK LDAP (https://github.com/dogtagpki/ldap-sdk/tree/master/c-sdk)Looks like it's multi licensed MPL 1.1/GPL.c) OpenLDAP (http://www.openldap.org/software/release/license.html)Looks like a BSD like license. 3) If the LDAP client / library is in base, then possibly name service switch and/or PAM with LDAP support could also be included in base.Just like we already have pam_krb5 in base. I hope I am not asking for too much. Since most of the above programs can be installed from ports. Finally, I am not a lawyer. Individual licenses should be read and proper legal counsel should be consulted as needed. Thanks,Patrick From owner-freebsd-hackers@freebsd.org Wed Aug 15 14:03:40 2018 Return-Path: Delivered-To: freebsd-hackers@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 05E2C1085CD1 for ; Wed, 15 Aug 2018 14:03:40 +0000 (UTC) (envelope-from driesm.michiels@gmail.com) Received: from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com [IPv6:2a00:1450:4864:20::52b]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 6E4AA8E8D3 for ; Wed, 15 Aug 2018 14:03:39 +0000 (UTC) (envelope-from driesm.michiels@gmail.com) Received: by mail-ed1-x52b.google.com with SMTP id h4-v6so870053edi.6 for ; Wed, 15 Aug 2018 07:03:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version:content-language :thread-index; bh=RnvY9AHy2/V6zLGSpXIfxnv1abF/RXqPToS8rfbjX+g=; b=o0NVmnBPlwpAXgrFB+YbR/ObjdPZIhgfk1I7vi6bl4ud1aYhgT+yinbSibXBPW146m JEeKj8C9tqjBymmwDQ5deJ8uU6fYEHm5Jzztu5N4oFmkfMu2Zq/BglMIdyrFfq8xZZCO DR/g4xt0KEYCbJCqmy6GRMuwPmc22iRHdBDCiIQAWILAkKxI3UpuLyIZdgUGSwLmpQUh f9IITC57l5yePvKeIFCh7IRMOMKAaQVv5HXs98cG9tjpQlNIdFptQekah5wBrQKj7pG1 7XNPhBNLTpecx0z9aJOpGCTy+IqhvAAMePOfuP/ZhH3VHwPFqjKPRBcCfVXihGE78tId JqQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-language:thread-index; bh=RnvY9AHy2/V6zLGSpXIfxnv1abF/RXqPToS8rfbjX+g=; b=G+uWbvsDjXQJiNdSyub44v8wl9+Eu8fLIoKXNW6wTMFYfwkp+hPWu04jI1sf6+1mnq zK6CBRU7ga4a6lu18BONDILM6M/Fx0obB/sFlVquIgsaLGUsh3KerPKxrzhO5yRWgrcS /ccl4OCCVuW6lM84yuUEbNQ62L0SOzlwj75hEOyloQVj0vatghjVr6TX5xQQtP88WRkL mEFtphTc7lWNGuBNyBfy6VKu3ac6YSfg0UDl1ZFpsatoI5r9GPrnG2paMigR2pFA6tXS G4aP7EKHbV00O6TEEB0PcZ55NofHYrOQVAIaOkgJR7aGDPHe2+AqKD9LetuOSTIkcNH/ ThZA== X-Gm-Message-State: AOUpUlEd1151B7HiPF1RANLFJow/dJWwbk7BpraKYFZc/bKNZ2OW+aKJ +BmLVWaVn22/Cksz66+CLy5x8jOvt2E= X-Google-Smtp-Source: AA+uWPx2B4wwt0epsqWfyyf53/SbbRt4OAb7E8T1Cg64chxwnGrmkpEMMQ045F2A7DGl/vnl4Ik1Cw== X-Received: by 2002:a50:8854:: with SMTP id c20-v6mr32271242edc.146.1534341818137; Wed, 15 Aug 2018 07:03:38 -0700 (PDT) Received: from DriesPC (94-224-232-102.access.telenet.be. [94.224.232.102]) by smtp.gmail.com with ESMTPSA id b44-v6sm20736875edd.93.2018.08.15.07.03.36 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 15 Aug 2018 07:03:37 -0700 (PDT) From: "Dries Michiels" To: Subject: Use absolute path for KERNCONF in make.conf Date: Wed, 15 Aug 2018 16:03:37 +0200 Message-ID: <001501d434a0$c3b8d8f0$4b2a8ad0$@gmail.com> MIME-Version: 1.0 X-Mailer: Microsoft Outlook 16.0 Content-Language: nl-be Thread-Index: AdQ0oDJAiMSBYcGASlKp/BnjFokBeg== Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Content-Filtered-By: Mailman/MimeDel 2.1.27 X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 15 Aug 2018 14:03:40 -0000 Hello, Is it possible to specify an absolute directory for kernel configurations in make.conf? Or does the specified name need to be present under /usr/src/sys/amd64/conf/KERNELNAME EG: KERNCONF = /root/KERNELNAME Thanks From owner-freebsd-hackers@freebsd.org Wed Aug 15 14:07:20 2018 Return-Path: Delivered-To: freebsd-hackers@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 67F761085E1D for ; Wed, 15 Aug 2018 14:07:20 +0000 (UTC) (envelope-from ian@freebsd.org) Received: from outbound1a.eu.mailhop.org (outbound1a.eu.mailhop.org [52.58.109.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id EE59F8EAA5 for ; Wed, 15 Aug 2018 14:07:19 +0000 (UTC) (envelope-from ian@freebsd.org) X-MHO-RoutePath: aGlwcGll X-MHO-User: 82f12811-a094-11e8-aff6-0b9b8210da61 X-Report-Abuse-To: https://support.duocircle.com/support/solutions/articles/5000540958-duocircle-standard-smtp-abuse-information X-Originating-IP: 67.177.211.60 X-Mail-Handler: DuoCircle Outbound SMTP Received: from ilsoft.org (unknown [67.177.211.60]) by outbound1.eu.mailhop.org (Halon) with ESMTPSA id 82f12811-a094-11e8-aff6-0b9b8210da61; Wed, 15 Aug 2018 14:07:15 +0000 (UTC) Received: from rev (rev [172.22.42.240]) by ilsoft.org (8.15.2/8.15.2) with ESMTP id w7FE7Eix074819; Wed, 15 Aug 2018 08:07:14 -0600 (MDT) (envelope-from ian@freebsd.org) Message-ID: <1534342034.31375.160.camel@freebsd.org> Subject: Re: Use absolute path for KERNCONF in make.conf From: Ian Lepore To: Dries Michiels , freebsd-hackers@freebsd.org Date: Wed, 15 Aug 2018 08:07:14 -0600 In-Reply-To: <001501d434a0$c3b8d8f0$4b2a8ad0$@gmail.com> References: <001501d434a0$c3b8d8f0$4b2a8ad0$@gmail.com> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.18.5.1 FreeBSD GNOME Team Port Mime-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 15 Aug 2018 14:07:20 -0000 On Wed, 2018-08-15 at 16:03 +0200, Dries Michiels wrote: > Hello, > >   > > Is it possible to specify an absolute directory for kernel > configurations in > make.conf? > > Or does the specified name need to be present under > /usr/src/sys/amd64/conf/KERNELNAME > >   > > EG: KERNCONF = /root/KERNELNAME > >   > > Thanks When I chased this down 5 or 6 years ago, I couldn't find any way to have an out-of-tree kernel config file other than to put a symlink into the src/sys//conf/ dir that points to the out-of-tree location (which is still a bit unsatisfying and requires a writable src tree). -- Ian From owner-freebsd-hackers@freebsd.org Wed Aug 15 15:14:16 2018 Return-Path: Delivered-To: freebsd-hackers@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 26993105B4D7 for ; Wed, 15 Aug 2018 15:14:16 +0000 (UTC) (envelope-from herbert@gojira.at) Received: from mail.bsd4all.net (mail.bsd4all.net [IPv6:2a01:4f8:191:217b::25]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mail.bsd4all.net", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id BD78591C16 for ; Wed, 15 Aug 2018 15:14:15 +0000 (UTC) (envelope-from herbert@gojira.at) Date: Wed, 15 Aug 2018 17:14:05 +0200 From: "Herbert J. Skuhra" To: freebsd-hackers@freebsd.org Subject: Re: Use absolute path for KERNCONF in make.conf Message-ID: <20180815151405.ct74pkx57sanfxpl@mail.bsd4all.net> References: <001501d434a0$c3b8d8f0$4b2a8ad0$@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <001501d434a0$c3b8d8f0$4b2a8ad0$@gmail.com> User-Agent: NeoMutt/20180716 X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 15 Aug 2018 15:14:16 -0000 On Wed, Aug 15, 2018 at 04:03:37PM +0200, Dries Michiels wrote: > Hello, > > > > Is it possible to specify an absolute directory for kernel configurations in > make.conf? > > Or does the specified name need to be present under > /usr/src/sys/amd64/conf/KERNELNAME > > > > EG: KERNCONF = /root/KERNELNAME KERNCONFDIR=/root ? -- Herbert From owner-freebsd-hackers@freebsd.org Thu Aug 16 09:47:48 2018 Return-Path: Delivered-To: freebsd-hackers@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 6A83D10842B9 for ; Thu, 16 Aug 2018 09:47:48 +0000 (UTC) (envelope-from driesm.michiels@gmail.com) Received: from mail-ed1-x52f.google.com (mail-ed1-x52f.google.com [IPv6:2a00:1450:4864:20::52f]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id C425F77836 for ; Thu, 16 Aug 2018 09:47:47 +0000 (UTC) (envelope-from driesm.michiels@gmail.com) Received: by mail-ed1-x52f.google.com with SMTP id t2-v6so2324345edr.5 for ; Thu, 16 Aug 2018 02:47:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:references:in-reply-to:subject:date:message-id:mime-version :content-transfer-encoding:thread-index:content-language; bh=zOrZVoQklE10zAhRTc21btyE3Nj1cKY8PI8dLEA9zSo=; b=FvCClcqi2OGA2lwG5H17CSna5YHQ6PDqf1X5k4UNgkG2OFMYDTTo1KhW0FuuJ0b2qN NtTntrMRiIqbot3Q51oS/j7rJGbjIlgpkxPSYqRSa7AH04e/3t3kHZ8mBHGXd8KiW0bC Lw7x/3QzE2PBJqy8BvE4OlvjOLu8PDDY7aB0qgCDreO0Dyp4BhqWratPISJIZ8mi0Top MHweCEQV8lqhkYlGvKs5wq/mgUCpNqa9gimdU6mu9gXSZOrs7eX3zesQTolZYPcQGgXk PwE4yIvrS15FJE91LOLdF3+Yj9ZFXEKxQ48JmBmMxhXTQ7Gnp7Osny9UurbO3AmQPnH+ HhZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:references:in-reply-to:subject:date :message-id:mime-version:content-transfer-encoding:thread-index :content-language; bh=zOrZVoQklE10zAhRTc21btyE3Nj1cKY8PI8dLEA9zSo=; b=hbr7zj+lXhSm0KXFBUMGPangG0DIN5yZCoDEa7a7zLDojwm3NHehLFY+JnhukwCuug DfFtxb8QMjtR3BsDyYxKFK9dlXhyB4NWp1DLFtt/5a6ikCwQvcfkS96IU6cIuJpfFzQL vL/mnlLJKTGoPZCHF9Ftbsh1AR4pVbFHC96VuhBphkcX3ckGPlScYDVs/0sS+m7AJu8L iNrmLHHMsT+d8SixV/IePVnWEpJuNIPSlr6keMg9IHyxn+SuAJh6K0WJaVjs+cCzVrBh +HC++bHpj6Sw5QH/OcDh2NUk16vUVB1qjF+hN02tEJ0tb/EGnsCCB3qrPv03MfkwtkEy En9Q== X-Gm-Message-State: AOUpUlGzX/F9ULOE4P3g0dyV1dvTkSZJNz45OcTtCeU9NPlRmjuE4VTT V9Jjaukihk3OHG71qH8ZyALCwIB0cfE= X-Google-Smtp-Source: AA+uWPy6tjtCwYBIJDl8jcwBEnJJCf0fCU8r/L7TcJmu4+JKhz7+0ZdezICiaJE4qUzR4NnJHyoQjA== X-Received: by 2002:a50:9f6f:: with SMTP id b102-v6mr37098133edf.219.1534412865806; Thu, 16 Aug 2018 02:47:45 -0700 (PDT) Received: from DriesPC (ptr-8si8ffc6u57941icpyb.18120a2.ip6.access.telenet.be. [2a02:1811:2503:1800:e91f:1e72:6c18:8463]) by smtp.gmail.com with ESMTPSA id h8-v6sm308328edi.68.2018.08.16.02.47.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Aug 2018 02:47:45 -0700 (PDT) From: "Dries Michiels" To: "'Herbert J. Skuhra'" , References: <001501d434a0$c3b8d8f0$4b2a8ad0$@gmail.com> <20180815151405.ct74pkx57sanfxpl@mail.bsd4all.net> In-Reply-To: <20180815151405.ct74pkx57sanfxpl@mail.bsd4all.net> Subject: RE: Use absolute path for KERNCONF in make.conf Date: Thu, 16 Aug 2018 11:47:46 +0200 Message-ID: <000001d43546$305cadb0$91160910$@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Outlook 16.0 Thread-Index: AQGMddq9KmQGWctU7jLnp6cwKWE3QwGMw7bSpUU6UJA= Content-Language: nl-be X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 16 Aug 2018 09:47:48 -0000 > On Wed, Aug 15, 2018 at 04:03:37PM +0200, Dries Michiels wrote: > > Hello, > > > > > > > > Is it possible to specify an absolute directory for kernel > > configurations in make.conf? > > > > Or does the specified name need to be present under > > /usr/src/sys/amd64/conf/KERNELNAME > > > > > > > > EG: KERNCONF = /root/KERNELNAME > > KERNCONFDIR=/root ? This works, thanks! > > -- > Herbert > _______________________________________________ From owner-freebsd-hackers@freebsd.org Thu Aug 16 16:28:36 2018 Return-Path: Delivered-To: freebsd-hackers@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 CAF77106CF24 for ; Thu, 16 Aug 2018 16:28:35 +0000 (UTC) (envelope-from doubleble@outlook.com) Received: from NAM02-BL2-obe.outbound.protection.outlook.com (mail-oln040092003066.outbound.protection.outlook.com [40.92.3.66]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (Client CN "mail.protection.outlook.com", Issuer "Microsoft IT TLS CA 4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 11DC18B7D2 for ; Thu, 16 Aug 2018 16:28:34 +0000 (UTC) (envelope-from doubleble@outlook.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=0aKi9+JF8PrAP2g3D4sxamQTB/c9IHbobJWoLn+zud8=; b=hOGHDtCGipX4jNdv/bxPnJJGO5YrkoyVBQ/lxHsfNFPY9ZOwDDF56luOzUBEvSkERo2GB4CE49S4vpyWVVDRQBUHiyIk5IUDxfBtFBdzE9594E0O94nWoSeTm5IV3LQwOAHl+RfG3hIGdfa7tSrawK4T8L2vFpEjXQDexCoJ8iGf5BEhC4t3FSqRdSedk0wFIFXLmQKmLgriCliwoRGozL01i9ztJToXvtIXpgK1dUIsKyhGC14z9CF81v3pi+rnoZEz4NyDLwJww+l97i/GjdmmiWSUp1EzPnmHOt5niiE5ug6mOkofmzqGNphsMdPlSrI7CpdSfdb6ABuLAYx2Pw== Received: from SN1NAM02FT008.eop-nam02.prod.protection.outlook.com (10.152.72.58) by SN1NAM02HT139.eop-nam02.prod.protection.outlook.com (10.152.73.223) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.1059.14; Thu, 16 Aug 2018 16:28:33 +0000 Received: from BN6PR2201MB1523.namprd22.prod.outlook.com (10.152.72.58) by SN1NAM02FT008.mail.protection.outlook.com (10.152.72.119) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.20.1059.14 via Frontend Transport; Thu, 16 Aug 2018 16:28:33 +0000 Received: from BN6PR2201MB1523.namprd22.prod.outlook.com ([fe80::4c9a:37fe:d25e:45e]) by BN6PR2201MB1523.namprd22.prod.outlook.com ([fe80::4c9a:37fe:d25e:45e%2]) with mapi id 15.20.1059.017; Thu, 16 Aug 2018 16:28:33 +0000 From: Double Tong To: "freebsd-hackers@freebsd.org" Subject: Create a thread with a separate file descriptor table (set RFFDG flag) Thread-Topic: Create a thread with a separate file descriptor table (set RFFDG flag) Thread-Index: AQHUNXm4sY9W87Z5LU6r9yREhH5aIQ== Date: Thu, 16 Aug 2018 16:28:33 +0000 Message-ID: Accept-Language: en-CA, zh-CN, en-US Content-Language: en-CA X-MS-Has-Attach: X-MS-TNEF-Correlator: x-incomingtopheadermarker: OriginalChecksum:E87CE54C87FFBFDEA1FA71A6EADE8416FF56B4B5374CF5DCBF905C76F5E1AD22; UpperCasedChecksum:9BCB135E09A2376DE7422D7F08610F4D0D542F241BE8BBAC41E14EF32FBC5FF9; SizeAsReceived:6995; Count:44 x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [DyUPIF8F0BKBqOuIIKId5nD15iAbKzJXZkduKaEbtUQ=] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; SN1NAM02HT139; 6:ouRRlHpei4nfc+gLR5bRcTpkHlkCFm8BKVQcqc5gvv3dsH9Vc1rHAh/ova1O4q3GoVGPqRUPvIta0oA55xLbYvvmCDxmALR0uBVTiTE0ILdqOUupiKN8yK31mpn5Vmj9fZrE7sNKYS7ouj0045X95qLNTsqbYgqFnG2e+70wFZ14Gi8QKtXXNi7gXkQBp9m/9o6hyDa/JSq3bKQfY658jf1wgyCOVhUtGXO6X5y0RcsksotW/FBYICz96uB/+RqQVlj5YYxgpoC++Im/SGQ0q1GMqXEh8Z2LdGaylbvs15rHQAb/8/a9qoQ9vocs/esYHrTVGUEJhhB9p4Z3Hn8AYz6XJX4nZFGAAiyymYtysca2q5/Dql+Fx8bM68lJh3bg7PoLWjBgbP0/hWSVgNHmRE2+u0fcXgZbzhJeeTbtu76vtyaUBkieaT5WadpmOmL3P38k5fPhjVR7l4OuT3npeA==; 5:T7O4qwmQ25rdN+admoe85hWWB+oH9XNNZvvsJXeIXVFWcq2YxgSn9T2S9Vbh7F4PngGydRhqfG3DWNtqrUEbRE4ISKs88+F6iOn4xbopqUjaP4ziWwZxlYp0ZIs0P8/bz/p6vIkd4WZinrn04cWmasPq9czorV1eyBzp9muV074=; 7:ScSQc3yhb6OiyXyUI/vDsvQaAcvyRnA5QhQPWZJ9m5XCwz4NPkNC6Q/mr+xPGy0J/76U60xACGSQptOyfubb2OawdlFXECppmhhuiE59OyoM6qFfFKXK6ZmunHqUgNYfmvd4pa70IkMziV+ECvcXkRwVId6YVL2zpoznN57lFLqgGxHVvGn7mu778SQSiqSbrR2rZrhNCpSCx2jCXMj4brj7QMeYo35YE8GRUPjJQwx9oqX2ozXtrP2XuOaeS39a x-incomingheadercount: 44 x-eopattributedmessage: 0 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(201702061078)(5061506573)(5061507331)(1603103135)(2017031320274)(2017031324274)(2017031323274)(2017031322404)(1603101475)(1601125500)(1701031045); SRVR:SN1NAM02HT139; x-ms-traffictypediagnostic: SN1NAM02HT139: x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(4566010)(82015058); SRVR:SN1NAM02HT139; BCL:0; PCL:0; RULEID:; SRVR:SN1NAM02HT139; x-forefront-prvs: 07665BE9D1 x-forefront-antispam-report: SFV:NSPM; SFS:(7070007)(189003)(501624003)(199004)(106356001)(25786009)(6306002)(6436002)(8676002)(105586002)(8936002)(2351001)(2501003)(5250100002)(26005)(6346003)(55016002)(6916009)(54896002)(5660300001)(5640700003)(20460500001)(102836004)(104016004)(82202002)(87572001)(105004)(56003)(476003)(345774005)(68736007)(426003)(5024004)(14444005)(14454004)(256004)(86362001)(2900100001)(99286004)(7696005)(486006)(74316002)(81156014)(97736004)(19627405001)(33656002); DIR:OUT; SFP:1901; SCL:1; SRVR:SN1NAM02HT139; H:BN6PR2201MB1523.namprd22.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: outlook.com does not designate permitted sender hosts) authentication-results: spf=none (sender IP is ) smtp.mailfrom=doubleble@outlook.com; x-microsoft-antispam-message-info: DthhwvYVugjka6AQLQ0kGUGnv2kejaRHW6zTh/U2UNI5wtg6ZzHji3rpNIgxhUbUXWecBJiEEGU3wqg5bNVcMuzSrDnOGcf2SHibf+9PrcNOm++cPH4iRH9iGwO1KaQPvubhMmdDFgXQq2/k5yHcmCNZt9/lY6YN2JFxAjvJHTnEoi5o0/QUtLSAV79Ao8o/0qgEjGzifp02nbG1oz+g3sl+1HxRn7njlFW8C/S8XI4= MIME-Version: 1.0 X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 9a4e3081-9524-43cf-bfc3-dcaef82d5da1 X-MS-Exchange-CrossTenant-Network-Message-Id: 86707581-2bde-4ff2-84b2-08d603954f1e X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 9a4e3081-9524-43cf-bfc3-dcaef82d5da1 X-MS-Exchange-CrossTenant-originalarrivaltime: 16 Aug 2018 16:28:33.1289 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1NAM02HT139 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.27 X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 16 Aug 2018 16:28:36 -0000 Hello, I want to create a thread with a separate file descriptor table to have bet= ter performance with kevent(2). On Linux, I was using unshare(2) syscall to= achieve this, which as far as I know there is no equivalent or similar sys= call in FreeBSD. I have posted on freebsd forums (https://forums.freebsd.org/threads/create-= a-thread-with-a-separate-file-descriptor-table-set-rffdg-flag.67143/), and = now I understood the following: rfork_thread(3) is deprecated in favor of = pthread_create(3). rfork_thread(3) is written in assembly language to perfo= rm stack swapping, which means if rfork_thread(3) no longer exists in the b= uild, it can damage our program's portability if it relies on rfork_thread. With the above consideration, I still have the following questions: 1. Is there an elegant way to create a thread with a separate file descr= iptor table? 2. If you are thinking about using rfork_thread(3) to do this, I am work= ing on this direction. I am using waitpid to join these "threads", and the = thread exits in the middle of execution with status 0x8b collected by waitp= id. I guess this status means invalid page access. I wrote a tiny program (= attached below) to reflect the code I am using in my program, I appreciate = if you would like to take a look at it to see if there is anything I was no= t doing correctly. 3. As I was reading the code of pthread_create, it allocates a pthread s= truct on the top of thread, and then calls clone, which freebsd implemented= its version of clone that actually calls rfork (I did not find the source = of freebsd's clone, can someone provides a link?). So I believe theoretical= ly there should be a way to achieve this in the user space. And if I am not= using pthread related APIs, then missing pthread struct should be fine as = well? 4. On Linux, after calling unshare(CLONE_FLIES), I got performance incre= ase around 10% with 1000 concurrent TCP connections. I am instructed to imp= lement this by my supervisor, and I do not have much details about why the = performance would increase. Would this also works for freebsd as well (keve= nt calls)? Thank you for any help, comments in advance! my_rfork_test.cc: -------------------------- // This program runs well, except status code is non zero. In my bigger pro= gram, it terminates in the middle of the routine with status 0x8b #include #include #include #include #include const size_t VEC_SIZE =3D 1000; static int thread_routine(void* arg) { std::cout<<"init thread "<** vectors =3D new std::vector*[VEC_SIZE]; for(int i =3D 0; i < VEC_SIZE; i++) { vectors[i] =3D new std::vector(10000); std::cout<<"vec "<(2)); int status =3D 0; waitpid(child, &status, 0x0); std::cout<<"return status 0x"< Delivered-To: freebsd-hackers@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 D9E2F106D8AF for ; Thu, 16 Aug 2018 16:38:54 +0000 (UTC) (envelope-from asomers@gmail.com) Received: from mail-lf1-x134.google.com (mail-lf1-x134.google.com [IPv6:2a00:1450:4864:20::134]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 3FA918C4C2 for ; Thu, 16 Aug 2018 16:38:54 +0000 (UTC) (envelope-from asomers@gmail.com) Received: by mail-lf1-x134.google.com with SMTP id o72-v6so1708691lfk.1 for ; Thu, 16 Aug 2018 09:38:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=m3oGd90k2enUrq4EIrLzEeGCv+RlUb64U02SPHobXR4=; b=Bbzkoqenr/LkbuIdGLwhh0i3vLWsrKjTVvDU/sqVm0PJVNLL5vC1migr0Y9/gFsIQS A2y+/4NzN2rjeSz91m1SJCZtW/eyQjrU1fldFnaALng6FfakLF47bvbOmrjrF3xCPUXN bMrKxqtZs/19UTsM4KzjbYgOl3YDpr4EHJdSRegxRtRk8/lq90xsuT66jp4i0VvaI9UQ yQyB/1DD0RjumBYNi/STFpmb1/Ca6Gxha4X5lWAqjQbzlj8fgEzOMHNYVJa9Y3krgr83 Yev6coL3LCNzQDmZCE0LkmyJ+V7JDPAknejL+kXFhS+chKUuzj7wZMRWONj9gBUMHEzX ggKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=m3oGd90k2enUrq4EIrLzEeGCv+RlUb64U02SPHobXR4=; b=TR1mirwIJi+28isGTAOHv797x4nwQ/JIeOX3VyRcA1K3B6WckMTWolQRbJzX+FedUY H8Y4UEMrtCp65ljeSV1KKDGybORaZ62ZyyShg8MN9VQ8UqS1KxJxRuQEsUCoG8GBsTKV L9iYlIqhnnXNj+sfnr9gqU7uJFegtaoRcFDaXNC+yRX6R5sIWWuCJg4QiVmG1n2lPCzX //58EAtbPhZhM3xIuTZvT6GCU6PgIEF1CZW8vZfZ8p/cs+BGgbJHkOAQj1oK8CWdi3CN cd4IDs+tqrYasgGXomUGRskeAYGJrluS+dtNFoBXrKnA9J7OiDzxgMDHA+t6xXZCxWdO jzDg== X-Gm-Message-State: AOUpUlFwcccVIjVsitBXwIrMlKgHAeOeiEPSMvNGxAJF0zfW9Is85jHo HiohQwD3AdCs7QRdKiOzN405cHPvYsWkSdt+0GszWA== X-Google-Smtp-Source: AA+uWPwgEzLgN43OJNhMhqy7sxgx9TjZcsuZHRNyQZ4pwJaG3/UzdMzLYSWCSz74tHI/+W86jRvtnxPHmFTSqd/zfGU= X-Received: by 2002:a19:d942:: with SMTP id q63-v6mr19174480lfg.39.1534437532514; Thu, 16 Aug 2018 09:38:52 -0700 (PDT) MIME-Version: 1.0 Sender: asomers@gmail.com Received: by 2002:ab3:7851:0:0:0:0:0 with HTTP; Thu, 16 Aug 2018 09:38:51 -0700 (PDT) In-Reply-To: References: From: Alan Somers Date: Thu, 16 Aug 2018 10:38:51 -0600 X-Google-Sender-Auth: JVTRMJOZv1fW7gPIoAR-DaSdSgA Message-ID: Subject: Re: Create a thread with a separate file descriptor table (set RFFDG flag) To: Double Tong Cc: "freebsd-hackers@freebsd.org" Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.27 X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 16 Aug 2018 16:38:55 -0000 On Thu, Aug 16, 2018 at 10:28 AM, Double Tong wrote: > Hello, > > I want to create a thread with a separate file descriptor table to have > better performance with kevent(2). On Linux, I was using unshare(2) syscall > to achieve this, which as far as I know there is no equivalent or similar > syscall in FreeBSD. > > I have posted on freebsd forums (https://forums.freebsd.org/ > threads/create-a-thread-with-a-separate-file-descriptor- > table-set-rffdg-flag.67143/), and now I understood the following: > rfork_thread(3) is deprecated in favor of pthread_create(3). > rfork_thread(3) is written in assembly language to perform stack swapping, > which means if rfork_thread(3) no longer exists in the build, it can damage > our program's portability if it relies on rfork_thread. > > With the above consideration, I still have the following questions: > > 1. Is there an elegant way to create a thread with a separate file > descriptor table? > Sort of. The usual way to do this is to create a separate process, not a separate thread. If you also need a shared address space, then you can probably satisfy that by creating a shared memory object, and using that for whichever data structures actually need to be shared. See shm_open(2) for details. > 2. If you are thinking about using rfork_thread(3) to do this, I am > working on this direction. I am using waitpid to join these "threads", and > the thread exits in the middle of execution with status 0x8b collected by > waitpid. I guess this status means invalid page access. I wrote a tiny > program (attached below) to reflect the code I am using in my program, I > appreciate if you would like to take a look at it to see if there is > anything I was not doing correctly. > 3. As I was reading the code of pthread_create, it allocates a pthread > struct on the top of thread, and then calls clone, which freebsd > implemented its version of clone that actually calls rfork (I did not find > the source of freebsd's clone, can someone provides a link?). So I believe > theoretically there should be a way to achieve this in the user space. And > if I am not using pthread related APIs, then missing pthread struct should > be fine as well? > 4. On Linux, after calling unshare(CLONE_FLIES), I got performance > increase around 10% with 1000 concurrent TCP connections. I am instructed > to implement this by my supervisor, and I do not have much details about > why the performance would increase. Would this also works for freebsd as > well (kevent calls)? Does your Linux program use select(2), epoll(2), or something else? select(2) has well-known performance problems with large file-descriptor tables, but epoll(2) and kevent(2) do not. If your program is using select(2), then you should convert it to use epoll(2)/kevent(2) and ditch unshare(2). > > Thank you for any help, comments in advance! > > -Alan From owner-freebsd-hackers@freebsd.org Fri Aug 17 08:44:51 2018 Return-Path: Delivered-To: freebsd-hackers@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 D291F1086EEF for ; Fri, 17 Aug 2018 08:44:51 +0000 (UTC) (envelope-from pratiy0100@gmail.com) Received: from mail-ed1-f49.google.com (mail-ed1-f49.google.com [209.85.208.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 59ADD72BA3; Fri, 17 Aug 2018 08:44:51 +0000 (UTC) (envelope-from pratiy0100@gmail.com) Received: by mail-ed1-f49.google.com with SMTP id j21-v6so4101677edp.10; Fri, 17 Aug 2018 01:44:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to:cc; bh=s7SnbU97Obriy8+bKhhaOcTmICSNm0/UyKkTP3IikPk=; b=PpGK53+eF4U96NKlFEu35VFOjOjWXeutVDK+A4wWJr2W2rZg3j0jDJaOMmcAnbscSc Np+2otOteCbPD6b2H0/EjqAVsJuN77k5IITiNDz3Q+33BR7LL+OS8WR2TqF2EA1UOLxq X0ZDsgTBNBUUZ3id+gzU+Hci7CUWett+fCTnahLAZk40ovWJjscWXOONUPKCcxUuUNtQ gsUSlneKIUdF94IfPFqsfBsJzxucdZzSZsn5oHqLsBvz2aAmxCL3NWEl7g53pd+qtgoR EIq3eGlTtSkzfqLv1uTBP0V/3lLvBA6UiAPIxjGQV6RfAbXSoXzVmPNn6bwANjaVnUrY OkrQ== X-Gm-Message-State: AOUpUlHcm6M6/IODWh9PZYnV3jgzPQr7tKkz8PsIbyemYr32VfNLMP0o MkmeZ88BIp7sBFZn6ppMWZCnJso3i0s= X-Google-Smtp-Source: AA+uWPzLLJn8mBcG+bJT8gxvyAjul5EO/GI0ItI+3sWrRgWLTNRRAkDjhauwOibWSVMzoe2vZ+umvw== X-Received: by 2002:a50:f9cb:: with SMTP id a11-v6mr40772470edq.26.1534492342045; Fri, 17 Aug 2018 00:52:22 -0700 (PDT) Received: from mail-ed1-f53.google.com (mail-ed1-f53.google.com. [209.85.208.53]) by smtp.gmail.com with ESMTPSA id a15-v6sm2655340edd.47.2018.08.17.00.52.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 17 Aug 2018 00:52:21 -0700 (PDT) Received: by mail-ed1-f53.google.com with SMTP id o8-v6so4026400edt.13; Fri, 17 Aug 2018 00:52:21 -0700 (PDT) X-Received: by 2002:a50:a9e2:: with SMTP id n89-v6mr40954810edc.158.1534492341532; Fri, 17 Aug 2018 00:52:21 -0700 (PDT) MIME-Version: 1.0 From: Pratyush Yadav Date: Fri, 17 Aug 2018 13:21:45 +0530 X-Gmail-Original-Message-ID: Message-ID: Subject: bus_dma(9): Is it allowed to load an already-loaded map? To: freebsd-hackers@freebsd.org Cc: =?UTF-8?Q?Roger_Pau_Monn=C3=A9?= Content-Type: text/plain; charset="UTF-8" X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 17 Aug 2018 08:44:52 -0000 Hi, I am writing an implementation of the bus_dma(9) interface for use with the Xen drivers, and I have a question: Is it allowed to load a dma map with an active mapping? The bus_dma(9) man page says: map A DMA map without a currently active mapping But, looking at the busdma_bounce (sys/x86/x86/busdma_bounce.c) code, it has no checks against this. On the contrary, it seems to support loading already-loaded maps. Maybe the interface allowed it earlier but removed support later. Or maybe it did not allow this earlier, and now it does, but the man page is just not updated. Can someone familiar with the details of the busdma system confirm? -- Regards, Pratyush Yadav From owner-freebsd-hackers@freebsd.org Fri Aug 17 06:18:36 2018 Return-Path: Delivered-To: freebsd-hackers@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 E4AB31083E44; Fri, 17 Aug 2018 06:18:35 +0000 (UTC) (envelope-from rajfbsd@gmail.com) Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 679268EA07; Fri, 17 Aug 2018 06:18:35 +0000 (UTC) (envelope-from rajfbsd@gmail.com) Received: by mail-wr1-x42c.google.com with SMTP id j5-v6so6086563wrr.8; Thu, 16 Aug 2018 23:18:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=5dqRCMPnNFB09uviXnmOpx7P68onljhWdSmjsNcWZRc=; b=lISGijaVQ4AlLmMNLPByM+Yy6I5A6S/Dh9r2EIAVlkvNKA4MWq2kVdLtMQX5vCvH7a Vi3HOSA+OKvXOeSVDlxxFqOwuWYYBYteFs7+FpNymZtCn9/2e80O58NS4iBwKv4+mCI3 r2ZeAsS1kT2wybHivdVGNw/3n4DWhEW/u5wnhrmEBjoNAGkpErc8fL1XCQjcWD2/JXyX ZkA31mm/fvhJlorpM0Oj/WwiQ0hKkyOXC1GX0ylvFe/3zgXhMXSgDvrF+7pt2ruIB7UQ 5KKkmdTKdQOs/x2VprQ9Nv65fxjdYHpGV/8m7hADVxTT5lZ5FW/7JAdu2YZkqiA3lkbY u1cA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=5dqRCMPnNFB09uviXnmOpx7P68onljhWdSmjsNcWZRc=; b=CUG642HcZyuqA2NEsUI3h7gpZEvtnxD6g+aA61OG1xlhnlUj/pDxmaAbXeflZnoXWj zN5y2Z2Y1sCUwDPTAl9skLo/IkQtXHbdyXWJj4/u0bTHlaOYbkXTwCq92MwodppKLiek AcAcBO+JrQQOU6ltpbXWXPpLnQnVbODeXnviDbKfelWgoYUC7h5fKg+/zAqeJMweyymK ceXRtj6uJqiOzCDuFfgEB3A/Pdy98jXkN4Tvq7irWaLgGAEbTkNuvFvZEov6ChjBMGN8 w9rE9QzmT+RNNqfS7bVQpC9qzwy1OkV+q09kZdLvc4awN1nwkJRPa6OTHfYGRgIszMED B+vA== X-Gm-Message-State: AOUpUlHwM98yJefybOMP+J53qGNj+HUJN9Zoe3lJWQSPJWqw9KfIJYtJ /GbBWTFxuZAUjPh35AFUDW0IkUmUCbvN30xfUalfaEQA X-Google-Smtp-Source: AA+uWPzVshDq4a84y0uKMgW1nT7phFlyaZUk/pBOUuoZtZcuQuUaigybXXdrXli1sb99WmQ7PDWAhcq8kurJb0kpS0Y= X-Received: by 2002:adf:9086:: with SMTP id i6-v6mr22343959wri.271.1534486714186; Thu, 16 Aug 2018 23:18:34 -0700 (PDT) MIME-Version: 1.0 From: Rajesh Kumar Date: Fri, 17 Aug 2018 11:48:22 +0530 Message-ID: Subject: Need a clarification regarding I2C bus frequency in FreeBSD To: freebsd-drivers@freebsd.org, freebsd-hackers@freebsd.org X-Mailman-Approved-At: Fri, 17 Aug 2018 10:25:31 +0000 Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.27 X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 17 Aug 2018 06:18:36 -0000 Hi, I am trying to use the I2C designware controller driver available in FreeBSD (ig4_iic.c) in our boards. Is there a clean way, I can set the I2C bus frequency from the controller driver itself, rather than using device hints, FDT, tunables etc., Something like, if the driver is loaded for our boards (identified using the PCI or ACPI ID's), then the frequency of the I2C bus needs to be hardcoded from driver itself. This is to avoid additional configs from the config file. I tried adding a new interface "iicbus_set_frequency" (in line with iicbus_get_frequency) and tried calling that from the ig4 driver after the "iicbus" child is added. But, iicbus instance is created only after ig4 driver is loaded. So, calling iicbus_set_frequency after child addition leads to system panic (as there is no iicbus softc at this point). Let me know if you need any details. Thanks, Rajesh. From owner-freebsd-hackers@freebsd.org Fri Aug 17 16:27:03 2018 Return-Path: Delivered-To: freebsd-hackers@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 E8A5E1074865 for ; Fri, 17 Aug 2018 16:27:02 +0000 (UTC) (envelope-from ian@freebsd.org) Received: from outbound1a.eu.mailhop.org (outbound1a.eu.mailhop.org [52.58.109.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 76083873AA for ; Fri, 17 Aug 2018 16:27:02 +0000 (UTC) (envelope-from ian@freebsd.org) X-MHO-RoutePath: aGlwcGll X-MHO-User: 5bbe0730-a23a-11e8-aff6-0b9b8210da61 X-Report-Abuse-To: https://support.duocircle.com/support/solutions/articles/5000540958-duocircle-standard-smtp-abuse-information X-Originating-IP: 67.177.211.60 X-Mail-Handler: DuoCircle Outbound SMTP Received: from ilsoft.org (unknown [67.177.211.60]) by outbound1.eu.mailhop.org (Halon) with ESMTPSA id 5bbe0730-a23a-11e8-aff6-0b9b8210da61; Fri, 17 Aug 2018 16:26:57 +0000 (UTC) Received: from rev (rev [172.22.42.240]) by ilsoft.org (8.15.2/8.15.2) with ESMTP id w7HGQu8a081010; Fri, 17 Aug 2018 10:26:56 -0600 (MDT) (envelope-from ian@freebsd.org) Message-ID: <1534523216.27158.17.camel@freebsd.org> Subject: Re: Need a clarification regarding I2C bus frequency in FreeBSD From: Ian Lepore To: Rajesh Kumar , freebsd-drivers@freebsd.org, freebsd-hackers@freebsd.org Date: Fri, 17 Aug 2018 10:26:56 -0600 In-Reply-To: References: Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.18.5.1 FreeBSD GNOME Team Port Mime-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 17 Aug 2018 16:27:03 -0000 On Fri, 2018-08-17 at 11:48 +0530, Rajesh Kumar wrote: > Hi, > > I am trying to use the I2C designware controller driver available in > FreeBSD (ig4_iic.c) in our boards. > > Is there a clean way, I can set the I2C bus frequency from the controller > driver itself, rather than using device hints, FDT, tunables etc., > Something like, if the driver is loaded for our boards (identified using > the PCI or ACPI ID's), then the frequency of the I2C bus needs to be > hardcoded from driver itself. This is to avoid additional configs from the > config file. > > I tried adding a new interface "iicbus_set_frequency" (in line with > iicbus_get_frequency) and tried calling that from the ig4 driver after the > "iicbus" child is added.  But, iicbus instance is created only after ig4 > driver is loaded. So, calling iicbus_set_frequency after child addition > leads to system panic (as there is no iicbus softc at this point). > > Let me know if you need any details. > > Thanks, > Rajesh. I don't really understand what you're asking for. The ig4_iic controller driver doesn't appear to support bus frequency settings at all, it just loads hard-coded values into the clock high/low registers and never changes them. If you want to locally modify the driver to run at a different hard-coded speed for your application, just change lines 589-592 in ig4_iic.c and continue to ignore the speed set by the bus driver when handling iicbus_reset. -- Ian From owner-freebsd-hackers@freebsd.org Sat Aug 18 10:11:09 2018 Return-Path: Delivered-To: freebsd-hackers@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 4F5AB108BAF4 for ; Sat, 18 Aug 2018 10:11:09 +0000 (UTC) (envelope-from doubleble@outlook.com) Received: from NAM01-BY2-obe.outbound.protection.outlook.com (mail-oln040092001048.outbound.protection.outlook.com [40.92.1.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (Client CN "mail.protection.outlook.com", Issuer "Microsoft IT TLS CA 4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 98AC78C070; Sat, 18 Aug 2018 10:11:08 +0000 (UTC) (envelope-from doubleble@outlook.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5dmO3CSm7OuoVDqP2HEqo1cUB80V79j8PXr58l9NQW0=; b=fUbQJqKifF8pgFrNLYZZsymJkHulrj8nTiZc3+Ht0UiRgTcnv9C6ySIlA88wPr3UgLTgsiIdgW+sFQ1FAoLzeX7/b/bbOUfib93cd/soV9ZKj2nlitK/ZRFKxDBJQlcK6xUko38crxYX5I3ER6bMPsQKNflMLk27mtpGjhvrKnPqbItMsw0OhrjwQhGCEWlS+9dUl0FDwGINoO67iFUp3cLeApyVHrJfN9mRCwdwN2exl9qz/YENumiprtbvLRvapNuMlURtfGD+We7AgIcjBBh1KsP92DnMjo3WXf6VAHzA148uBuSsl3YWJQYalW/jJWfhuKwxfwJbuRACUKtRmA== Received: from BN3NAM01FT008.eop-nam01.prod.protection.outlook.com (10.152.66.55) by BN3NAM01HT182.eop-nam01.prod.protection.outlook.com (10.152.67.98) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.20.1080.9; Sat, 18 Aug 2018 10:11:06 +0000 Received: from BN6PR2201MB1523.namprd22.prod.outlook.com (10.152.66.55) by BN3NAM01FT008.mail.protection.outlook.com (10.152.67.73) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.20.1080.9 via Frontend Transport; Sat, 18 Aug 2018 10:11:06 +0000 Received: from BN6PR2201MB1523.namprd22.prod.outlook.com ([fe80::4c9a:37fe:d25e:45e]) by BN6PR2201MB1523.namprd22.prod.outlook.com ([fe80::4c9a:37fe:d25e:45e%2]) with mapi id 15.20.1059.023; Sat, 18 Aug 2018 10:11:06 +0000 From: Double Tong To: Alan Somers CC: "freebsd-hackers@freebsd.org" Subject: Re: Create a thread with a separate file descriptor table (set RFFDG flag) Thread-Topic: Create a thread with a separate file descriptor table (set RFFDG flag) Thread-Index: AQHUNXm4sY9W87Z5LU6r9yREhH5aIaTClEaAgAK1FYA= Date: Sat, 18 Aug 2018 10:11:06 +0000 Message-ID: References: , In-Reply-To: Accept-Language: en-CA, zh-CN, en-US Content-Language: en-CA X-MS-Has-Attach: X-MS-TNEF-Correlator: x-incomingtopheadermarker: OriginalChecksum:E63E6D51D1013AC45B0A4A89EFE21AE84D4F05E4436621FDA7D97C236769FE6E; UpperCasedChecksum:052208DBD2331FEC3871F976E99EAF8CD468817E6625B845AD9DD43DC9761CDB; SizeAsReceived:7321; Count:47 x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [7BnyNqIlIvvoxNnkIl20zTmLuo4UE9vC] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; BN3NAM01HT182; 6:fQp2XLcosY1MgOcZruc6pkMh8NdEF2CbpWXA+Lu2AD0N6QI3yIpOEFBHPrVWLMsQ3WRuSonbqEiG4vkYK+DU/DuER49h0fJpAHi4kuPmGrCH+ja8NIG54M7UUWKl6DVQl1bxLtOIpq1Y1fMWPPNfqQ6eAMmb7LWisUe/gnMxpvos4PPtXXwt9ondO+1vWYadJH0Y8aQC1Ou8DTUwLNHY4atJBXRD9mli/1VERfdT6c74tXfzvFv5W3bfF/61V1i98MfQ6WQBfniGTd63gsmh5vB9V7ZPWWVcxX2b7Bne2YPiCtHA4jYVySpV7AtPS7znhzJXq5r67HN1QymUp4STw7Ep6aOcW+f5UwhwYf1nkAdFdUgIjvcpguXNpOcT9MeIhB/ZIzkGsCZLamvaDII6k+xMXZChIX29gXHpRK+Ut3nMOr0rpzHuCak7LiLCLHyDitRdYFaESwicjl4OEO6gVA==; 5:awjh9Q4wBZxUW80Tk27LCeuYRSCIkFNDEM4/XmrIjU97pGFWFsZeT5UnNbNtYzAblkLbjJ3o0O3aDR2krikCkfs7MddSM8MHTE5wT+syK5ib6gxBhc+LX158HLdsJvW18nK4cCjfgwXXvhPt85/6OU4FoXp+BVengWQ3qtjTBts=; 7:eahmRIM6AS/BOGhCZC/RNWbJeXFd4ofDQDKUiOlXoeNWisUjdMht0QJ1xPm80a9HnN0br2GhQpoFfOGM4VEjbjSrQfNK2jJY5jJnhaZ8FOKOjm7KEbhtNrvaFiVcpcedHRvrQfauBdzsdAMIW/TY7g3UEfGNIZgeeOOEek/kL0MuACLL4wtQ2/Ui3cklXMp3XRdFauJsqRm5BBYFE/cRi2RP9I9iiJ/ab+aq3XUmq0VvQTEnyZ2lA5cipwTTy81w x-incomingheadercount: 47 x-eopattributedmessage: 0 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(201702061078)(5061506573)(5061507331)(1603103135)(2017031320274)(2017031324274)(2017031323274)(2017031322404)(1603101475)(1601125500)(1701031045); SRVR:BN3NAM01HT182; x-ms-traffictypediagnostic: BN3NAM01HT182: x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(4566010)(82015058); SRVR:BN3NAM01HT182; BCL:0; PCL:0; RULEID:; SRVR:BN3NAM01HT182; x-forefront-prvs: 076804FE30 x-forefront-antispam-report: SFV:NSPM; SFS:(7070007)(199004)(189003)(501624003)(6916009)(5250100002)(82202002)(99286004)(5660300001)(8676002)(8936002)(2900100001)(81156014)(345774005)(54896002)(55016002)(6306002)(486006)(256004)(14444005)(33656002)(86362001)(5024004)(19627405001)(87572001)(236005)(476003)(104016004)(229853002)(20460500001)(68736007)(6436002)(606006)(25786009)(105586002)(106356001)(76176011)(97736004)(6246003)(4326008)(450100002)(7696005)(11346002)(446003)(426003)(45080400002)(105004)(14454004)(102836004)(6346003)(53546011)(26005)(56003)(74316002); DIR:OUT; SFP:1901; SCL:1; SRVR:BN3NAM01HT182; H:BN6PR2201MB1523.namprd22.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: outlook.com does not designate permitted sender hosts) authentication-results: spf=none (sender IP is ) smtp.mailfrom=doubleble@outlook.com; x-microsoft-antispam-message-info: n3b26mDbGYUJIr6stgY9K/gsse+SYIAhtq7CVdE9ROQ02DB2cCbN3nG4NQv1n8JFfC5ix7C9wVX+XTNslE0m8yG8QrLwSr5wa4+jPmJ4F5bCeWSiAGnxmlgzgwNNvZuxvhhQC1yzfwHC/mVc5jlyKFtboQz4YZKVHl5OsAKr1YAKRGG05hWue60oU8Jffj6I+Qlw8+o6UNuDWXGvVg2lwYVDIV579nmndYg1Nw17G4g= MIME-Version: 1.0 X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 9a4e3081-9524-43cf-bfc3-dcaef82d5da1 X-MS-Exchange-CrossTenant-Network-Message-Id: 302e4b8a-414f-4e0e-0d6d-08d604f2e96a X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 9a4e3081-9524-43cf-bfc3-dcaef82d5da1 X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Aug 2018 10:11:06.2735 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN3NAM01HT182 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.27 X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 18 Aug 2018 10:11:09 -0000 Thank you Alan! As the program's main structure is mostly done, using shared memory object = to help coping with this issue requires too much work for us. We did not us= e any select calls. I was told the performance gain can be greater if these= connections are short-lived (i.e. one connection transmit one request). I = will try it later to get some data. And on Linux it is easy to do, simply a= unshare(2) syscall would do it, which is why we are considering doing this= on FreeBSD as well. Anyway it is something nice to have, not something tha= t would block the project. I am still interested my question 2 and 3, as theoretically, it feels like = the idea should work. Thanks, -Shuangyi Tong ________________________________ From: asomers@gmail.com on behalf of Alan Somers Sent: August 16, 2018 12:38 To: Double Tong Cc: freebsd-hackers@freebsd.org Subject: Re: Create a thread with a separate file descriptor table (set RFF= DG flag) On Thu, Aug 16, 2018 at 10:28 AM, Double Tong > wrote: Hello, I want to create a thread with a separate file descriptor table to have bet= ter performance with kevent(2). On Linux, I was using unshare(2) syscall to= achieve this, which as far as I know there is no equivalent or similar sys= call in FreeBSD. I have posted on freebsd forums (https://forums.freebsd.org/threads/create-= a-thread-with-a-separate-file-descriptor-table-set-rffdg-flag.67143/), and = now I understood the following: rfork_thread(3) is deprecated in favor of = pthread_create(3). rfork_thread(3) is written in assembly language to perfo= rm stack swapping, which means if rfork_thread(3) no longer exists in the b= uild, it can damage our program's portability if it relies on rfork_thread. With the above consideration, I still have the following questions: 1. Is there an elegant way to create a thread with a separate file descr= iptor table? Sort of. The usual way to do this is to create a separate process, not a s= eparate thread. If you also need a shared address space, then you can prob= ably satisfy that by creating a shared memory object, and using that for wh= ichever data structures actually need to be shared. See shm_open(2) for de= tails. 2. If you are thinking about using rfork_thread(3) to do this, I am work= ing on this direction. I am using waitpid to join these "threads", and the = thread exits in the middle of execution with status 0x8b collected by waitp= id. I guess this status means invalid page access. I wrote a tiny program (= attached below) to reflect the code I am using in my program, I appreciate = if you would like to take a look at it to see if there is anything I was no= t doing correctly. 3. As I was reading the code of pthread_create, it allocates a pthread s= truct on the top of thread, and then calls clone, which freebsd implemented= its version of clone that actually calls rfork (I did not find the source = of freebsd's clone, can someone provides a link?). So I believe theoretical= ly there should be a way to achieve this in the user space. And if I am not= using pthread related APIs, then missing pthread struct should be fine as = well? 4. On Linux, after calling unshare(CLONE_FLIES), I got performance incre= ase around 10% with 1000 concurrent TCP connections. I am instructed to imp= lement this by my supervisor, and I do not have much details about why the = performance would increase. Would this also works for freebsd as well (keve= nt calls)? Does your Linux program use select(2), epoll(2), or something else? select= (2) has well-known performance problems with large file-descriptor tables, = but epoll(2) and kevent(2) do not. If your program is using select(2), the= n you should convert it to use epoll(2)/kevent(2) and ditch unshare(2). Thank you for any help, comments in advance! -Alan