From patchwork Wed Feb 3 11:42:42 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leon Romanovsky X-Patchwork-Id: 8201201 Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id E59429F6DA for ; Wed, 3 Feb 2016 11:44:14 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0DF7D201DD for ; Wed, 3 Feb 2016 11:44:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BD400201B9 for ; Wed, 3 Feb 2016 11:44:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751308AbcBCLoJ (ORCPT ); Wed, 3 Feb 2016 06:44:09 -0500 Received: from mail-wm0-f44.google.com ([74.125.82.44]:38883 "EHLO mail-wm0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754512AbcBCLoG (ORCPT ); Wed, 3 Feb 2016 06:44:06 -0500 Received: by mail-wm0-f44.google.com with SMTP id p63so66064636wmp.1 for ; Wed, 03 Feb 2016 03:44:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=leon-nu.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=jUrrhnYmQsG/Re9cDdG7EkYLl7Th8CBo91cJrV1IyrM=; b=gZ/4BuaB71HgZ5/O3+DR6ivrQKwTmlo04YPNvk+dYbLFCTvbuoLwXGuimNjGKBJHOR XA/bncGro8zfa57Gh5NZTe8csOLFT1OlMLt14rS8x/t/Jn1cVmNqk7z7c5pSb5aLhr5x HF3S/1phSRq6p/tu/kY28tp7xX1irdt2226YByWXm5RWfwM5T5VFENpwWaUh7nx9JiwT Jnpi7iG6dGpvDZn0k/eJ2kciDZnLSdvAFGg8nVPTB945L/j0QoTL9MURETkMw7jiceTF AYh15DjNSf5GYVihDfqzrqa3VCP7SjUn9xSw1QPqHBUDTbcJTQtOBQdvNF0FNcwucU/k YRKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=jUrrhnYmQsG/Re9cDdG7EkYLl7Th8CBo91cJrV1IyrM=; b=Ik8+1Ddk8AFj/SN1UOBVzdDVm5Ethx/DNm8dm0A9vA0+4hbywk2aLkBpUVe/so01T5 ui1Q5qiRgunR3oygJGZ7owHQ0ioOcNZ6AKnUTEKFIbltMbaJ42XY+qx7t0IhpkFzzaBL vqPzqzBqKL9A9FWBXRRSR8aVUilGDyfzIqtwbQ9t3FIt6z0uTdtr0Y+F02K09raJjzoA epkLO5PpXwXCeqfPbsIGbCbSFAXBKUfVld0eJxU4nVhp3KB4rzmLRyLFgpIZBvm8z3PL WS3qfSe7xUNk8OQkFjRDxRkLADn/mDa3qpBUkIHdoHi1jZ9jnfcHFDcIcx3khzKynnNl TTTQ== X-Gm-Message-State: AG10YORfGEsR1YD/hXM7kRE7h2Vg7/eVyrTJDJ2YuO0+YVPEt1d3uWEsnD7N215d/sRwgA== X-Received: by 10.195.13.201 with SMTP id fa9mr1586723wjd.68.1454499844953; Wed, 03 Feb 2016 03:44:04 -0800 (PST) Received: from localhost ([193.47.165.251]) by smtp.gmail.com with ESMTPSA id cb2sm6112593wjc.16.2016.02.03.03.44.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Feb 2016 03:44:04 -0800 (PST) From: Leon Romanovsky To: dledford@redhat.com Cc: yosefe@mellanox.com, linux-rdma@vger.kernel.org, Leon Romanovsky Subject: [PATCH libibverbs] Allow use of huge pages in multiple calls to ibv_fork_init Date: Wed, 3 Feb 2016 13:42:42 +0200 Message-Id: <1454499762-29819-1-git-send-email-leon@leon.nu> X-Mailer: git-send-email 2.1.4 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Leon Romanovsky Setting the environment variable RDMAV_HUGEPAGES_SAFE tells the library to check the underlying page size used by the kernel for memory regions. This is required if an application uses huge pages either directly or indirectly via a library such as libhugetlbfs. The check of this variable was performed at the first call to ibv_fork_init. This caused to unpredicted behavior in complex applications with multiple underlying libraries. The proposed change will allow support of huge pages without relying on ibv_fork_init calls order. Signed-off-by: Leon Romanovsky --- src/memory.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/memory.c b/src/memory.c index e9d1eecd9eab..89509c6e356f 100644 --- a/src/memory.c +++ b/src/memory.c @@ -140,6 +140,9 @@ int ibv_fork_init(void) int ret; unsigned long size; + if (getenv("RDMAV_HUGEPAGES_SAFE")) + huge_page_enabled = 1; + if (mm_root) return 0; @@ -153,11 +156,6 @@ int ibv_fork_init(void) if (posix_memalign(&tmp, page_size, page_size)) return ENOMEM; - if (getenv("RDMAV_HUGEPAGES_SAFE")) - huge_page_enabled = 1; - else - huge_page_enabled = 0; - if (huge_page_enabled) { size = get_page_size(tmp); tmp_aligned = (void *) ((uintptr_t) tmp & ~(size - 1));