From owner-svn-src-all@freebsd.org Mon Oct 19 15:01:39 2015 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id BBBEAA19D59; Mon, 19 Oct 2015 15:01:39 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 50EAD1DB1; Mon, 19 Oct 2015 15:01:39 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kostik@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id t9JF1USi095505 (version=TLSv1 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO); Mon, 19 Oct 2015 18:01:30 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua t9JF1USi095505 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id t9JF1UVO095504; Mon, 19 Oct 2015 18:01:30 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Mon, 19 Oct 2015 18:01:30 +0300 From: Konstantin Belousov To: Hans Petter Selasky Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r289565 - head/sys/ofed/include/linux Message-ID: <20151019150130.GK2257@kib.kiev.ua> References: <201510191056.t9JAuWhF052021@repo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201510191056.t9JAuWhF052021@repo.freebsd.org> User-Agent: Mutt/1.5.24 (2015-08-30) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on tom.home X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 Oct 2015 15:01:39 -0000 On Mon, Oct 19, 2015 at 10:56:32AM +0000, Hans Petter Selasky wrote: > Author: hselasky > Date: Mon Oct 19 10:56:32 2015 > New Revision: 289565 > URL: https://svnweb.freebsd.org/changeset/base/289565 > > Log: > Merge LinuxKPI changes from DragonflyBSD: > - Implement pagefault_disable() and pagefault_enable(). > > Sponsored by: Mellanox Technologies > > Modified: > head/sys/ofed/include/linux/uaccess.h > > Modified: head/sys/ofed/include/linux/uaccess.h > ============================================================================== > --- head/sys/ofed/include/linux/uaccess.h Mon Oct 19 10:54:24 2015 (r289564) > +++ head/sys/ofed/include/linux/uaccess.h Mon Oct 19 10:56:32 2015 (r289565) > @@ -2,7 +2,8 @@ > * Copyright (c) 2010 Isilon Systems, Inc. > * Copyright (c) 2010 iX Systems, Inc. > * Copyright (c) 2010 Panasas, Inc. > - * Copyright (c) 2013, 2014 Mellanox Technologies, Ltd. > + * Copyright (c) 2013-2015 Mellanox Technologies, Ltd. > + * Copyright (c) 2015 Fran??ois Tigeot > * All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > @@ -32,4 +33,14 @@ > #define get_user(_x, _p) -copyin((_p), &(_x), sizeof(*(_p))) > #define put_user(_x, _p) -copyout(&(_x), (_p), sizeof(*(_p))) > > +static inline void pagefault_disable(void) > +{ > + curthread_pflags_set(TDP_NOFAULTING | TDP_RESETSPUR); > +} > + > +static inline void pagefault_enable(void) > +{ > + curthread_pflags_restore(~(TDP_NOFAULTING | TDP_RESETSPUR)); > +} > + > #endif /* _LINUX_UACCESS_H_ */ This is wrong on many counts. First, we already provide the wrappers to implement the nofaulting behaviour, see vm_fault_disable_pagefaults() and vm_fault_enable_pagefaults(). Second, your implementation ignores possible recursion on the state, unconditionally re-enabling faulting, and more seriously, it unconditionally obliterates the spurious faults tracker. The return value from vm_fault_disable_pagefaults() is there for the reason, and if Linux KPI does not have a place to store the state, some replacement must be implemented instead of silently corrupting the flags on enable.