From patchwork Tue Oct 15 18:12:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 11191373 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 95F21139A for ; Tue, 15 Oct 2019 18:16:21 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 54477222C2 for ; Tue, 15 Oct 2019 18:16:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b="gOR7v+Ma" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 54477222C2 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 796B68E0008; Tue, 15 Oct 2019 14:16:16 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 720698E0001; Tue, 15 Oct 2019 14:16:16 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6123F8E0008; Tue, 15 Oct 2019 14:16:16 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0137.hostedemail.com [216.40.44.137]) by kanga.kvack.org (Postfix) with ESMTP id 40F6F8E0001 for ; Tue, 15 Oct 2019 14:16:16 -0400 (EDT) Received: from smtpin27.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with SMTP id DA9B66131 for ; Tue, 15 Oct 2019 18:16:15 +0000 (UTC) X-FDA: 76046823510.27.chalk81_36a01f215e654 X-Spam-Summary: 2,0,0,14e3c462c2d6927b,d41d8cd98f00b204,jgg@ziepe.ca,:jglisse@redhat.com:rcampbell@nvidia.com:jhubbard@nvidia.com:felix.kuehling@amd.com:linux-rdma@vger.kernel.org::aarcange@redhat.com:dri-devel@lists.freedesktop.org:amd-gfx@lists.freedesktop.org:bskeggs@redhat.com:jgg@mellanox.com,RULES_HIT:41:355:379:541:800:960:973:988:989:1260:1311:1314:1345:1359:1431:1437:1515:1535:1543:1711:1730:1747:1777:1792:2393:2559:2562:3138:3139:3140:3141:3142:3352:3865:3867:3868:3870:3871:3872:3874:4117:4321:4605:5007:6120:6261:6653:7576:7875:7901:9010:9592:10004:10226:11026:11473:11658:11914:12043:12048:12291:12296:12297:12438:12517:12519:12555:12679:12683:12895:12986:13255:13894:13972:14096:14110:14181:14394:14721:21080:21324:21325:21444:21451:21627:30045:30054,0,RBL:209.85.166.68:@ziepe.ca:.lbl8.mailshell.net-62.2.175.100 66.100.201.201,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY :none X-HE-Tag: chalk81_36a01f215e654 X-Filterd-Recvd-Size: 6817 Received: from mail-io1-f68.google.com (mail-io1-f68.google.com [209.85.166.68]) by imf15.hostedemail.com (Postfix) with ESMTP for ; Tue, 15 Oct 2019 18:16:15 +0000 (UTC) Received: by mail-io1-f68.google.com with SMTP id b136so48187087iof.3 for ; Tue, 15 Oct 2019 11:16:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=XcVBi9ccgY4WcIiK7htGW9JC/41ZVBDU/dZyJbvS0oI=; b=gOR7v+Magpr20tPpBhw3su5vwBWD1crfNwZ0Z9VwQerZXk4VmKtv7ZGa/jZLOy3+Gb K/Q7dJA5LKZQavy+GhBoux2L8kxb3css4d9zN/qzJ6D9qjLAybfSGz5wAW9Oa8BkSVtJ te/l388bPwiD/m6Mv210cwaQmHe4ZhGHpALba4ndH4+4j9LOZ5xQuVmuzT9Du8DYtThP FU5+UPGU4MiMeGISYSD3jjKBdkSmM33uzAoSWwQ4tizM9raO+SKggS9Hv63dzChlpFDC P9lGy5CTBdU2CwXQdDQ23RO44PDQ6aNgRYtT68MI+iv+KJ0S/ruk9IdofQwJd83rujzd zcxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=XcVBi9ccgY4WcIiK7htGW9JC/41ZVBDU/dZyJbvS0oI=; b=K3cE6cZM7lKDG6yH9TGX+5ubkTCJxJPwwWGNq7oP1dbFqFDwHMlejhNpaXCJeXXvHq U8rlMIo7NNVZZplcqrePIQuVvLgx/eRLg59ZYfUYv08HUIeNZ8z7DePLFItCEf+V1D3O cjbT33xkbNIwf7Z7nJGe5MMT87yqyVXbDR4iySJJ/tGEylNo55rPjG3d+Y9DbBsqYOaE bDV1fEGhS3wSweJzkbAQp7iyHs7hnXJj1ylRgog1QLzdBLohUDy0mQAfJPp5EIjZprIS MouDR8ZwRlyvZf1+vuUTKuW8ZrVmMLSsPXRzfxw3uPB6fLMpY9iKm5dzPgbvXQOnAG/R xefg== X-Gm-Message-State: APjAAAV3LxfnFc384HCr8bX2jXmu2FdkI+RwH1u0DI2NYM8aY1Hg2a7s YK3PYICP02FzFFDrM3oai2Zg6g== X-Google-Smtp-Source: APXvYqyx9iOETMkWQM2sfKJTNRp/60e+N/aCImQtCZIAbTEsdBubG9IKWgw/xkcAPqe/1cFrooZISw== X-Received: by 2002:a5d:9e02:: with SMTP id h2mr26817595ioh.137.1571163374432; Tue, 15 Oct 2019 11:16:14 -0700 (PDT) Received: from ziepe.ca ([24.114.26.129]) by smtp.gmail.com with ESMTPSA id m11sm14366395ioq.5.2019.10.15.11.16.13 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 15 Oct 2019 11:16:13 -0700 (PDT) Received: from jgg by jggl.ziepe.ca with local (Exim 4.90_1) (envelope-from ) id 1iKRJT-0002C1-CW; Tue, 15 Oct 2019 15:12:51 -0300 From: Jason Gunthorpe To: Jerome Glisse , Ralph Campbell , John Hubbard , Felix.Kuehling@amd.com Cc: linux-rdma@vger.kernel.org, linux-mm@kvack.org, Andrea Arcangeli , dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, Ben Skeggs , Jason Gunthorpe Subject: [PATCH hmm 04/15] mm/hmm: define the pre-processor related parts of hmm.h even if disabled Date: Tue, 15 Oct 2019 15:12:31 -0300 Message-Id: <20191015181242.8343-5-jgg@ziepe.ca> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191015181242.8343-1-jgg@ziepe.ca> References: <20191015181242.8343-1-jgg@ziepe.ca> MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Jason Gunthorpe Only the function calls are stubbed out with static inlines that always fail. This is the standard way to write a header for an optional component and makes it easier for drivers that only optionally need HMM_MIRROR. Signed-off-by: Jason Gunthorpe Reviewed-by: Jérôme Glisse --- include/linux/hmm.h | 59 ++++++++++++++++++++++++++++++++++++--------- kernel/fork.c | 1 - 2 files changed, 47 insertions(+), 13 deletions(-) diff --git a/include/linux/hmm.h b/include/linux/hmm.h index 8ac1fd6a81af8f..2666eb08a40615 100644 --- a/include/linux/hmm.h +++ b/include/linux/hmm.h @@ -62,8 +62,6 @@ #include #include -#ifdef CONFIG_HMM_MIRROR - #include #include #include @@ -374,6 +372,15 @@ struct hmm_mirror { struct list_head list; }; +/* + * Retry fault if non-blocking, drop mmap_sem and return -EAGAIN in that case. + */ +#define HMM_FAULT_ALLOW_RETRY (1 << 0) + +/* Don't fault in missing PTEs, just snapshot the current state. */ +#define HMM_FAULT_SNAPSHOT (1 << 1) + +#ifdef CONFIG_HMM_MIRROR int hmm_mirror_register(struct hmm_mirror *mirror, struct mm_struct *mm); void hmm_mirror_unregister(struct hmm_mirror *mirror); @@ -383,14 +390,6 @@ void hmm_mirror_unregister(struct hmm_mirror *mirror); int hmm_range_register(struct hmm_range *range, struct hmm_mirror *mirror); void hmm_range_unregister(struct hmm_range *range); -/* - * Retry fault if non-blocking, drop mmap_sem and return -EAGAIN in that case. - */ -#define HMM_FAULT_ALLOW_RETRY (1 << 0) - -/* Don't fault in missing PTEs, just snapshot the current state. */ -#define HMM_FAULT_SNAPSHOT (1 << 1) - long hmm_range_fault(struct hmm_range *range, unsigned int flags); long hmm_range_dma_map(struct hmm_range *range, @@ -401,6 +400,44 @@ long hmm_range_dma_unmap(struct hmm_range *range, struct device *device, dma_addr_t *daddrs, bool dirty); +#else +int hmm_mirror_register(struct hmm_mirror *mirror, struct mm_struct *mm) +{ + return -EOPNOTSUPP; +} + +void hmm_mirror_unregister(struct hmm_mirror *mirror) +{ +} + +int hmm_range_register(struct hmm_range *range, struct hmm_mirror *mirror) +{ + return -EOPNOTSUPP; +} + +void hmm_range_unregister(struct hmm_range *range) +{ +} + +static inline long hmm_range_fault(struct hmm_range *range, unsigned int flags) +{ + return -EOPNOTSUPP; +} + +static inline long hmm_range_dma_map(struct hmm_range *range, + struct device *device, dma_addr_t *daddrs, + unsigned int flags) +{ + return -EOPNOTSUPP; +} + +static inline long hmm_range_dma_unmap(struct hmm_range *range, + struct device *device, + dma_addr_t *daddrs, bool dirty) +{ + return -EOPNOTSUPP; +} +#endif /* * HMM_RANGE_DEFAULT_TIMEOUT - default timeout (ms) when waiting for a range @@ -411,6 +448,4 @@ long hmm_range_dma_unmap(struct hmm_range *range, */ #define HMM_RANGE_DEFAULT_TIMEOUT 1000 -#endif /* IS_ENABLED(CONFIG_HMM_MIRROR) */ - #endif /* LINUX_HMM_H */ diff --git a/kernel/fork.c b/kernel/fork.c index f9572f41612628..4561a65d19db88 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -40,7 +40,6 @@ #include #include #include -#include #include #include #include