lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20210528182746.GA3645229@nvidia.com>
Date:   Fri, 28 May 2021 15:27:46 -0300
From:   Jason Gunthorpe <jgg@...dia.com>
To:     Leon Romanovsky <leon@...nel.org>
Cc:     Doug Ledford <dledford@...hat.com>,
        Avihai Horon <avihaih@...dia.com>,
        linux-kernel@...r.kernel.org, linux-rdma@...r.kernel.org
Subject: Re: [PATCH rdma-next v1 1/2] RDMA: Enable Relaxed Ordering by
 default for kernel ULPs

On Thu, May 20, 2021 at 01:13:35PM +0300, Leon Romanovsky wrote:
> diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
> index 05dbc216eb64..b7bda44e9189 100644
> +++ b/include/rdma/ib_verbs.h
> @@ -1440,7 +1440,7 @@ enum ib_access_flags {
>  	IB_ZERO_BASED = IB_UVERBS_ACCESS_ZERO_BASED,
>  	IB_ACCESS_ON_DEMAND = IB_UVERBS_ACCESS_ON_DEMAND,
>  	IB_ACCESS_HUGETLB = IB_UVERBS_ACCESS_HUGETLB,
> -	IB_ACCESS_RELAXED_ORDERING = IB_UVERBS_ACCESS_RELAXED_ORDERING,
> +	IB_ACCESS_DISABLE_RELAXED_ORDERING = IB_UVERBS_ACCESS_OPTIONAL_FIRST,
>  
>  	IB_ACCESS_OPTIONAL = IB_UVERBS_ACCESS_OPTIONAL_RANGE,
>  	IB_ACCESS_SUPPORTED =

IB_ACCESS_SUPPORTED should be deleted too

> -				 IB_ACCESS_SUPPORTED);
> +				 ((IB_UVERBS_ACCESS_HUGETLB << 1) - 1) |
> +					 IB_UVERBS_ACCESS_OPTIONAL_RANGE);

This would do well as a IB_UVERBS_ACCESS_MR_SUPPORTED constant

> @@ -4679,4 +4679,70 @@ static inline u32 rdma_calc_flow_label(u32 lqpn, u32 rqpn)
>  
>  const struct ib_port_immutable*
>  ib_port_immutable_read(struct ib_device *dev, unsigned int port);
> +
> +static inline void process_access_flag(unsigned int *dest_flags,
> +				       unsigned int out_flag,
> +				       unsigned int *src_flags,
> +				       unsigned int in_flag)
> +{
> +	if (!(*src_flags & in_flag))
> +		return;
> +
> +	*dest_flags |= out_flag;
> +	*src_flags &= ~in_flag;
> +}
> +
> +static inline void process_access_flag_inv(unsigned int *dest_flags,
> +					   unsigned int out_flag,
> +					   unsigned int *src_flags,
> +					   unsigned int in_flag)
> +{
> +	if (*src_flags & in_flag) {
> +		*dest_flags &= ~out_flag;
> +		*src_flags &= ~in_flag;
> +		return;
> +	}
> +
> +	*dest_flags |= out_flag;
> +}
> +
> +static inline int copy_mr_access_flags(unsigned int *dest_flags,
> +				       unsigned int src_flags)
> +{
> +	*dest_flags = 0;
> +
> +	process_access_flag(dest_flags, IB_ACCESS_LOCAL_WRITE, &src_flags,
> +			    IB_UVERBS_ACCESS_LOCAL_WRITE);
> +
> +	process_access_flag(dest_flags, IB_ACCESS_REMOTE_WRITE, &src_flags,
> +			    IB_UVERBS_ACCESS_REMOTE_WRITE);
> +
> +	process_access_flag(dest_flags, IB_ACCESS_REMOTE_READ, &src_flags,
> +			    IB_UVERBS_ACCESS_REMOTE_READ);
> +
> +	process_access_flag(dest_flags, IB_ACCESS_REMOTE_ATOMIC, &src_flags,
> +			    IB_UVERBS_ACCESS_REMOTE_ATOMIC);
> +
> +	process_access_flag(dest_flags, IB_ACCESS_MW_BIND, &src_flags,
> +			    IB_UVERBS_ACCESS_MW_BIND);
> +
> +	process_access_flag(dest_flags, IB_ZERO_BASED, &src_flags,
> +			    IB_UVERBS_ACCESS_ZERO_BASED);
> +
> +	process_access_flag(dest_flags, IB_ACCESS_ON_DEMAND, &src_flags,
> +			    IB_UVERBS_ACCESS_ON_DEMAND);
> +
> +	process_access_flag(dest_flags, IB_ACCESS_HUGETLB, &src_flags,
> +			    IB_UVERBS_ACCESS_HUGETLB);
> +
> +	process_access_flag_inv(dest_flags, IB_ACCESS_DISABLE_RELAXED_ORDERING,
> +				&src_flags, IB_UVERBS_ACCESS_RELAXED_ORDERING);

This seems over complicated, why not just:

dst_flags = IB_ACCESS_DISABLE_RELAXED_ORDERING
if (src_flags & IB_UVERBS_ACCESS_LOCAL_WRITE)
    dst_flags |= IB_ACCESS_LOCAL_WRITE;
if (src_flags & IB_UVERBS_ACCESS_RELAXED_ORDERING)
    dst_flags &= ~IB_ACCESS_DISABLE_RELAXED_ORDERING;

if (src_flags & ~IB_UVERBS_ACCESS_MR_SUPPORTED)
  return -EINVAL;

And the QP version is the same as the MR, just with a different
supported flags check

Jason

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ