From owner-freebsd-current@FreeBSD.ORG Fri May 29 12:37:59 2015 Return-Path: Delivered-To: current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id C5AFD646 for ; Fri, 29 May 2015 12:37:59 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3C68F1181 for ; Fri, 29 May 2015 12:37:59 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kostik@localhost [127.0.0.1]) by kib.kiev.ua (8.14.9/8.14.9) with ESMTP id t4TCbrbY070148 (version=TLSv1/SSLv3 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO); Fri, 29 May 2015 15:37:53 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.9.2 kib.kiev.ua t4TCbrbY070148 Received: (from kostik@localhost) by tom.home (8.14.9/8.14.9/Submit) id t4TCbrSu070147; Fri, 29 May 2015 15:37:53 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Fri, 29 May 2015 15:37:53 +0300 From: Konstantin Belousov To: Luigi Rizzo Cc: FreeBSD Current , Giuseppe Lettieri Subject: Re: per file descriptor device driver data ? Message-ID: <20150529123753.GF2499@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.5.23 (2014-03-12) 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-current@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 May 2015 12:37:59 -0000 On Fri, May 29, 2015 at 02:24:14PM +0200, Luigi Rizzo wrote: > Hi, > in the kernel module for netmap we need to store some > private data associated to each open netmap file descriptor. > > Our current design uses devfs_set_cdevpriv() during the open() > handler, but for some reason a subsequent devfs_get_cdevpriv(p) > returns *p = NULL in additional threads created by the process > that did the open(). > > The manpage devfs_set_cdevpriv() does not mention threads, > and so i am a bit puzzled why the cdevpriv is only good > for the original thread. Probably, due to a bug, and the bug is more likely in the consumer code, than in cdevpriv. The cdevpriv requires the current file context, i.e. you should be in the context of the syscall which is operating on the file, to get the file related private data. If you believe that the bug is in cdevpriv interface, please provide the minimal example to demonstrate the issue. > > In the linux version 'struct file' has a "private_data" field > that we use for that purpose, and remains valid on all threads. > i wonder if there is something similar we can use in FreeBSD.