Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756765AbcDHCMN (ORCPT ); Thu, 7 Apr 2016 22:12:13 -0400 Received: from mail-bn1on0136.outbound.protection.outlook.com ([157.56.110.136]:21504 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753274AbcDHCML convert rfc822-to-8bit (ORCPT ); Thu, 7 Apr 2016 22:12:11 -0400 From: Dexuan Cui To: Joe Perches , "gregkh@linuxfoundation.org" , "davem@davemloft.net" , "netdev@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "devel@linuxdriverproject.org" , "olaf@aepfle.de" , "apw@canonical.com" , "jasowang@redhat.com" , "cavery@redhat.com" , KY Srinivasan , Haiyang Zhang CC: "vkuznets@redhat.com" Subject: RE: [PATCH v8 net-next 1/1] hv_sock: introduce Hyper-V Sockets Thread-Topic: [PATCH v8 net-next 1/1] hv_sock: introduce Hyper-V Sockets Thread-Index: AQHRkTQbkMP3SNDrDEyjwQM7LvBJx59/TMmg Date: Fri, 8 Apr 2016 01:56:06 +0000 Message-ID: References: <1460079411-31982-1-git-send-email-decui@microsoft.com> <1460078109.1800.16.camel@perches.com> In-Reply-To: <1460078109.1800.16.camel@perches.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: perches.com; dkim=none (message not signed) header.d=none;perches.com; dmarc=none action=none header.from=microsoft.com; x-originating-ip: [2404:f801:9000:18::14c] x-ms-office365-filtering-correlation-id: 695af96e-447e-4305-fcbc-08d35f50f2d8 x-microsoft-exchange-diagnostics: 1;BLUPR03MB1412;5:ptAyr1tNfjZorIlWoaJoGBPcUt9Tm7v2S3ZNNXOCVGH34KGemYO2L2eg0Yu6oJei02H323FVmJE/zEeVaFobJVxdtkFNzGeu2rzR5P3NKUTYoK2Y0IsDBuVHJZlLEOdoCpyvXe6kvOMFeltHdvvcWw==;24:Ny9bFgu43ULXXSGNKmPYR+2zkKRevHbIcp2boq1bRBdy5G7GUN831ANkqsqEjqqUWhesneEhDfJdyxdAypj/JV1aI9/idns9L6yzlVHHmh4= x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BLUPR03MB1412; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(61425038)(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046)(6055026)(61426038)(61427038);SRVR:BLUPR03MB1412;BCL:0;PCL:0;RULEID:;SRVR:BLUPR03MB1412; x-forefront-prvs: 0906E83A25 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(6009001)(24454002)(377424004)(2561002)(5008740100001)(19580395003)(3280700002)(5005710100001)(76176999)(4326007)(189998001)(19580405001)(81166005)(106116001)(3660700001)(1096002)(2501003)(50986999)(1220700001)(33656002)(2906002)(102836003)(9686002)(86362001)(6116002)(586003)(86612001)(54356999)(164054004)(76576001)(122556002)(87936001)(1511001)(2421001)(74316001)(5003600100002)(99286002)(5002640100001)(4001450100002)(5004730100002)(10090500001)(2900100001)(10400500002)(2950100001)(77096005)(92566002)(10290500002)(5001770100001)(921003)(3826002)(1121003);DIR:OUT;SFP:1102;SCL:1;SRVR:BLUPR03MB1412;H:BLUPR03MB1410.namprd03.prod.outlook.com;FPR:;SPF:None;MLV:sfv;LANG:en; spamdiagnosticoutput: 1:23 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Apr 2016 01:56:06.3669 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR03MB1412 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1436 Lines: 44 > From: Joe Perches [mailto:joe@perches.com] > Sent: Friday, April 8, 2016 9:15 > On Thu, 2016-04-07 at 18:36 -0700, Dexuan Cui wrote: > > diff --git a/include/net/af_hvsock.h b/include/net/af_hvsock.h > [] > > +#define VMBUS_RINGBUFFER_SIZE_HVSOCK_RECV (5 * PAGE_SIZE) > > +#define VMBUS_RINGBUFFER_SIZE_HVSOCK_SEND (5 * PAGE_SIZE) > > + > > +#define HVSOCK_RCV_BUF_SZ > VMBUS_RINGBUFFER_SIZE_HVSOCK_RECV > > +#define HVSOCK_SND_BUF_SZ PAGE_SIZE > [] > > +struct hvsock_sock { > [] > > + struct { > > + struct vmpipe_proto_header hdr; > > + char buf[HVSOCK_SND_BUF_SZ]; > > + } __packed send; > > + > > + struct { > > + struct vmpipe_proto_header hdr; > > + char buf[HVSOCK_RCV_BUF_SZ]; > > + unsigned int data_len; > > + unsigned int data_offset; > > + } __packed recv; > > +}; > > These bufs are not page aligned and so can span pages. > > Is there any value in allocating these bufs separately > as pages instead of as a kmalloc? The bufs are not required to be page aligned. Here the 'hdr' and the 'buf' must be consecutive, i.e., the 'buf' must be an array rather than a pointer: please see hvsock_send_data(). It looks to me there is no big value to make sure the 'buf' is page aligned: on x86_64, at least it should already be 8-byte aligned due to the adjacent channel pointer, so memcpy_from_msg() should work enough good and in hvsock_send_data() -> vmbus_sendpacket(), we don't copy the 'buf'. Thanks, -- Dexuan