From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753103AbZHZTuE (ORCPT ); Wed, 26 Aug 2009 15:50:04 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753016AbZHZTuD (ORCPT ); Wed, 26 Aug 2009 15:50:03 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43379 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752912AbZHZTuC (ORCPT ); Wed, 26 Aug 2009 15:50:02 -0400 Date: Wed, 26 Aug 2009 22:50:02 +0300 From: Gleb Natapov To: Avi Kivity Cc: Davide Libenzi , "Michael S. Tsirkin" , kvm@vger.kernel.org, Linux Kernel Mailing List Subject: Re: [PATCH 0/2] eventfd: new EFD_STATE flag Message-ID: <20090826195002.GE11762@redhat.com> References: <20090824214900.GA9899@redhat.com> <20090825072229.GA10608@redhat.com> <20090826102908.GA21523@redhat.com> <4A9585EC.2030505@redhat.com> <4A95900D.9090201@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4A95900D.9090201@redhat.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 26, 2009 at 10:42:05PM +0300, Avi Kivity wrote: > On 08/26/2009 10:13 PM, Davide Libenzi wrote: > >Ok, so why not using the eventfd counter as state? > >On the device side: > > > >void write_state(int sfd, int state) { > > u64 cnt; > > > > /* Clear the current state, sfd is in non-blocking mode */ > > read(sfd,&cnt, sizeof(cnt)); > > /* Writes new state */ > > cnt = 1 + !!state; > > write(sfd,&cnt, sizeof(cnt)); > >} > > > > > >On the hypervisor side: > > > >int read_state(int sfd) { > > u64 cnt; > > > > read(sfd,&cnt, sizeof(cnt)); > > return state - 1; > >} > > > > Hadn't though of read+write as set. While the 1+ is a little ugly, > it's workable. > It's two system calls instead of one to inject interrupt. > I see no kernel equivalent to read(), but that's easily done. > -- Gleb.