Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C2816C433E6 for ; Wed, 3 Feb 2021 02:59:58 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id EEBAC64F68 for ; Wed, 3 Feb 2021 02:59:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EEBAC64F68 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=aj.id.au Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=openbmc-bounces+openbmc=archiver.kernel.org@lists.ozlabs.org Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 4DVmcr1q49zDwgq for ; Wed, 3 Feb 2021 13:59:56 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=aj.id.au (client-ip=66.111.4.25; helo=out1-smtp.messagingengine.com; envelope-from=andrew@aj.id.au; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=aj.id.au header.i=@aj.id.au header.a=rsa-sha256 header.s=fm1 header.b=Gb6vF6OC; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm2 header.b=i9b4aH3E; dkim-atps=neutral Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4DVhvj0k4YzDqcY for ; Wed, 3 Feb 2021 11:12:32 +1100 (AEDT) Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 92AE95C0219; Tue, 2 Feb 2021 19:12:26 -0500 (EST) Received: from imap2 ([10.202.2.52]) by compute3.internal (MEProxy); Tue, 02 Feb 2021 19:12:26 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aj.id.au; h= mime-version:message-id:in-reply-to:references:date:from:to:cc :subject:content-type; s=fm1; bh=n3Jpv30wXeHEhJ9WckSU3BGDSlGaHEo ftD2etpNhPAY=; b=Gb6vF6OCdsxDKPHYARghvYRRflrdiURPQn1+MbMhYX9h0Nf KOGQV5PgwOQkLjtW9CEE5mqqAf42hO5+A4euZ72lAa++7sTAtKBAzItDeULUU4hJ jza00DG6/s8+oDWlLw0Y6vQE8RoB5BaKtYVMghv/BdMDzAwcpQOoLj1KdyWOduYw RAUgElXeWDuUl4ng/Jw+dTKA0WH3FwG5dpDmuOeVnP957pXxIJA7HDjMMJ9sMFJj ottLdFXfzaDvlNdKK15uw2NAs0dqsvbWO0hZFyjsf5yjjIRb4FbEHmRrO/nOuIDn aP8cekk+2BOtRjMKUcbvgXCf5/pYojtZ8q33j1w== 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-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=n3Jpv3 0wXeHEhJ9WckSU3BGDSlGaHEoftD2etpNhPAY=; b=i9b4aH3ElUOOlK8VTvbbv8 GLTz3p1PdqG8+VI3dIyn1pz2/2ePtlaVKtbzdsQ09mbh74VGboIiFkmpZaUS3ZM+ h+woo/jE3lxptWAxgb5Ju6yvj9IPMIzLaF7+dOzNJQXEuFFfr7f6z6EbOEMDESZj P3nNP5cuWEwbOUk5QlnRW3V4YCxIxgrr+v9Fbfh1YMde9uWRP6bpNLV5UD++MgMr b3g2QbzFm2/QcK0E5godMv3SY4JQf/zaq/ryQHJmjJI2WtcxSns++d1dozdLSCsM jJsmtOomiq4J0s4CzPoRv8twyHRXU1y7ytp1VTuGDQcYPhSJ9xuregF4FT4HMrUg == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrgedugddukecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefofgggkfgjfhffhffvufgtsehttdertderredtnecuhfhrohhmpedftehnughr vgifucflvghffhgvrhihfdcuoegrnhgurhgvfiesrghjrdhiugdrrghuqeenucggtffrrg htthgvrhhnpeelkefgffekteejhfdtfffgveejvedvvdevgeduudffuddukefhhfekvefg iedtffenucffohhmrghinhepghhithhhuhgsrdgtohhmnecuvehluhhsthgvrhfuihiivg eptdenucfrrghrrghmpehmrghilhhfrhhomheprghnughrvgifsegrjhdrihgurdgruh X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id 43239A0005D; Tue, 2 Feb 2021 19:12:24 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.5.0-alpha0-93-gef6c4048e6-fm-20210128.002-gef6c4048 Mime-Version: 1.0 Message-Id: <09f8bed7-e19e-4ce9-850f-ae870ae89937@www.fastmail.com> In-Reply-To: References: <31abd546-4538-ecf0-134e-b8e48e75b3ad@linux.intel.com> Date: Wed, 03 Feb 2021 10:41:46 +1030 From: "Andrew Jeffery" To: "Ed Tanous" , "Bills, Jason M" Subject: Re: Sensor Value PropertiesChanged Events Content-Type: text/plain X-BeenThere: openbmc@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development list for OpenBMC List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jeremy Kerr , "openbmc@lists.ozlabs.org" Errors-To: openbmc-bounces+openbmc=archiver.kernel.org@lists.ozlabs.org Sender: "openbmc" On Tue, 2 Feb 2021, at 11:56, Ed Tanous wrote: > > The third one is a little more out there. We could change the > sensor.Value.Value property into an FD type, and point to a memmapped > area of memory into which we write the current sensor value. That > way, the "sensor value" on dbus rarely changes, but you can always > read the current state of the sensor with zero overhead or context > switching to the sensor processes. If this works, it has the > potential to speed up most sensor polling operations by an order of > magnitude, but seems hard to do, and has a lot of questions. Does > inotify work on mmaped files? How do FD permissions work when sent > over dbus? How do you "lock" the memory region to write it (or do you > not have to)? > So... a little repo that I pushed recently might help out with this approach: https://github.com/amboar/shmapper It's a shared-memory implementation of the mapper daemon, but setting that aside for the moment, the implementation contains a shared library, libshmap, discussed in the README: https://github.com/amboar/shmapper#libshmap libshmap allows you to treat process-shared-memory like regular heap memory*, and also wraps up the pthread locking and condition signalling primitives in a way that they can be placed into the shared memory region without concern. So in brief, you could implement your out-there idea on top of libshmap, and it has solutions for most of the questions you list there already: * Permissions would be enforced by ownership of the sensor shared library (libraries?) built on top of libshmap. * Locking the memory regions can be done with shmap_mutex or shmap_rwlock, and * Notification can be done using shmap_mutex and shmap_condition I've been thinking about how I could do condition notification over a file-descriptor so you could poll it for updates to the shared memory. I haven't got anything concrete yet, but that would provide async monitoring too. Cheers, Andrew