Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754329AbdCPWL7 (ORCPT ); Thu, 16 Mar 2017 18:11:59 -0400 Received: from mail-pf0-f194.google.com ([209.85.192.194]:33264 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752017AbdCPWL5 (ORCPT ); Thu, 16 Mar 2017 18:11:57 -0400 Message-ID: <1489702304.28631.251.camel@edumazet-glaptop3.roam.corp.google.com> Subject: Re: [net-next PATCH 5/5] epoll: Add busy poll support to epoll with socket fds. From: Eric Dumazet To: Alexander Duyck Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, sridhar.samudrala@intel.com, edumazet@google.com, davem@davemloft.net Date: Thu, 16 Mar 2017 15:11:44 -0700 In-Reply-To: <20170316183302.15806.2645.stgit@localhost.localdomain> References: <20170316183142.15806.38824.stgit@localhost.localdomain> <20170316183302.15806.2645.stgit@localhost.localdomain> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.10.4-0ubuntu2 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 573 Lines: 21 On Thu, 2017-03-16 at 11:33 -0700, Alexander Duyck wrote: > From: Sridhar Samudrala > +/* > + * If busy polling is on and the file is a socket, return a pointer to > + * struct sock > + */ > +static inline struct sock *ep_sk_from_file(struct file *file) > +{ > + struct inode *inode = file_inode(file); > + > + if (!S_ISSOCK(inode->i_mode)) > + return NULL; > + > + return ((struct socket *)file->private_data)->sk; > +} I believe a more standard way is to use sock_from_file() (This does not have to fetch a cache line to read i_mode ))