All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] xen/grant-table: remove unnecessary BUG_ON on gnttab_interface
@ 2019-12-15 20:13 ` Aditya Pakki
  0 siblings, 0 replies; 4+ messages in thread
From: Aditya Pakki @ 2019-12-15 20:13 UTC (permalink / raw)
  To: pakki001
  Cc: kjlu, Boris Ostrovsky, Juergen Gross, Stefano Stabellini,
	xen-devel, linux-kernel

grow_gnttab_list() checks for NULL on gnttab_interface immediately
after gnttab_expand() check. The patch removes the redundant assertion
and replaces the BUG_ON call with recovery code.

Signed-off-by: Aditya Pakki <pakki001@umn.edu>
---
 drivers/xen/grant-table.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/xen/grant-table.c b/drivers/xen/grant-table.c
index 49b381e104ef..f59694c352be 100644
--- a/drivers/xen/grant-table.c
+++ b/drivers/xen/grant-table.c
@@ -664,7 +664,6 @@ static int grow_gnttab_list(unsigned int more_frames)
 	unsigned int nr_glist_frames, new_nr_glist_frames;
 	unsigned int grefs_per_frame;
 
-	BUG_ON(gnttab_interface == NULL);
 	grefs_per_frame = gnttab_interface->grefs_per_grant_frame;
 
 	new_nr_grant_frames = nr_grant_frames + more_frames;
@@ -1388,7 +1387,9 @@ static int gnttab_expand(unsigned int req_entries)
 	int rc;
 	unsigned int cur, extra;
 
-	BUG_ON(gnttab_interface == NULL);
+	if (!gnttab_interface)
+		return -EINVAL;
+
 	cur = nr_grant_frames;
 	extra = ((req_entries + gnttab_interface->grefs_per_grant_frame - 1) /
 		 gnttab_interface->grefs_per_grant_frame);
@@ -1423,7 +1424,9 @@ int gnttab_init(void)
 	/* Determine the maximum number of frames required for the
 	 * grant reference free list on the current hypervisor.
 	 */
-	BUG_ON(gnttab_interface == NULL);
+	if (!gnttab_interface)
+		return -EINVAL;
+
 	max_nr_glist_frames = (max_nr_grant_frames *
 			       gnttab_interface->grefs_per_grant_frame / RPP);
 
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [Xen-devel] [PATCH] xen/grant-table: remove unnecessary BUG_ON on gnttab_interface
@ 2019-12-15 20:13 ` Aditya Pakki
  0 siblings, 0 replies; 4+ messages in thread
From: Aditya Pakki @ 2019-12-15 20:13 UTC (permalink / raw)
  To: pakki001
  Cc: Juergen Gross, Stefano Stabellini, kjlu, linux-kernel, xen-devel,
	Boris Ostrovsky

grow_gnttab_list() checks for NULL on gnttab_interface immediately
after gnttab_expand() check. The patch removes the redundant assertion
and replaces the BUG_ON call with recovery code.

Signed-off-by: Aditya Pakki <pakki001@umn.edu>
---
 drivers/xen/grant-table.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/xen/grant-table.c b/drivers/xen/grant-table.c
index 49b381e104ef..f59694c352be 100644
--- a/drivers/xen/grant-table.c
+++ b/drivers/xen/grant-table.c
@@ -664,7 +664,6 @@ static int grow_gnttab_list(unsigned int more_frames)
 	unsigned int nr_glist_frames, new_nr_glist_frames;
 	unsigned int grefs_per_frame;
 
-	BUG_ON(gnttab_interface == NULL);
 	grefs_per_frame = gnttab_interface->grefs_per_grant_frame;
 
 	new_nr_grant_frames = nr_grant_frames + more_frames;
@@ -1388,7 +1387,9 @@ static int gnttab_expand(unsigned int req_entries)
 	int rc;
 	unsigned int cur, extra;
 
-	BUG_ON(gnttab_interface == NULL);
+	if (!gnttab_interface)
+		return -EINVAL;
+
 	cur = nr_grant_frames;
 	extra = ((req_entries + gnttab_interface->grefs_per_grant_frame - 1) /
 		 gnttab_interface->grefs_per_grant_frame);
@@ -1423,7 +1424,9 @@ int gnttab_init(void)
 	/* Determine the maximum number of frames required for the
 	 * grant reference free list on the current hypervisor.
 	 */
-	BUG_ON(gnttab_interface == NULL);
+	if (!gnttab_interface)
+		return -EINVAL;
+
 	max_nr_glist_frames = (max_nr_grant_frames *
 			       gnttab_interface->grefs_per_grant_frame / RPP);
 
-- 
2.20.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] xen/grant-table: remove unnecessary BUG_ON on gnttab_interface
  2019-12-15 20:13 ` [Xen-devel] " Aditya Pakki
@ 2019-12-16  7:38   ` Jürgen Groß
  -1 siblings, 0 replies; 4+ messages in thread
From: Jürgen Groß @ 2019-12-16  7:38 UTC (permalink / raw)
  To: Aditya Pakki
  Cc: kjlu, Boris Ostrovsky, Stefano Stabellini, xen-devel, linux-kernel

On 15.12.19 21:13, Aditya Pakki wrote:
> grow_gnttab_list() checks for NULL on gnttab_interface immediately
> after gnttab_expand() check. The patch removes the redundant assertion
> and replaces the BUG_ON call with recovery code.
> 
> Signed-off-by: Aditya Pakki <pakki001@umn.edu>
> ---
>   drivers/xen/grant-table.c | 9 ++++++---
>   1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/xen/grant-table.c b/drivers/xen/grant-table.c
> index 49b381e104ef..f59694c352be 100644
> --- a/drivers/xen/grant-table.c
> +++ b/drivers/xen/grant-table.c
> @@ -664,7 +664,6 @@ static int grow_gnttab_list(unsigned int more_frames)
>   	unsigned int nr_glist_frames, new_nr_glist_frames;
>   	unsigned int grefs_per_frame;
>   
> -	BUG_ON(gnttab_interface == NULL);
>   	grefs_per_frame = gnttab_interface->grefs_per_grant_frame;
>   
>   	new_nr_grant_frames = nr_grant_frames + more_frames;
> @@ -1388,7 +1387,9 @@ static int gnttab_expand(unsigned int req_entries)
>   	int rc;
>   	unsigned int cur, extra;
>   
> -	BUG_ON(gnttab_interface == NULL);
> +	if (!gnttab_interface)
> +		return -EINVAL;
> +
>   	cur = nr_grant_frames;
>   	extra = ((req_entries + gnttab_interface->grefs_per_grant_frame - 1) /
>   		 gnttab_interface->grefs_per_grant_frame);
> @@ -1423,7 +1424,9 @@ int gnttab_init(void)
>   	/* Determine the maximum number of frames required for the
>   	 * grant reference free list on the current hypervisor.
>   	 */
> -	BUG_ON(gnttab_interface == NULL);
> +	if (!gnttab_interface)
> +		return -EINVAL;
> +

I'd just remove the BUG_ON().

gnttab_request_version() called some lines up always sets
gnttab_interface.

The BUG_ON() in nr_status_frames() can be removed, too. It is either
called by v2 specific functions (for those to be reached
gnttab_interface must be set) or by gnttab_init() (reasoning see
above).


Juergen

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Xen-devel] [PATCH] xen/grant-table: remove unnecessary BUG_ON on gnttab_interface
@ 2019-12-16  7:38   ` Jürgen Groß
  0 siblings, 0 replies; 4+ messages in thread
From: Jürgen Groß @ 2019-12-16  7:38 UTC (permalink / raw)
  To: Aditya Pakki
  Cc: xen-devel, Boris Ostrovsky, Stefano Stabellini, kjlu, linux-kernel

On 15.12.19 21:13, Aditya Pakki wrote:
> grow_gnttab_list() checks for NULL on gnttab_interface immediately
> after gnttab_expand() check. The patch removes the redundant assertion
> and replaces the BUG_ON call with recovery code.
> 
> Signed-off-by: Aditya Pakki <pakki001@umn.edu>
> ---
>   drivers/xen/grant-table.c | 9 ++++++---
>   1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/xen/grant-table.c b/drivers/xen/grant-table.c
> index 49b381e104ef..f59694c352be 100644
> --- a/drivers/xen/grant-table.c
> +++ b/drivers/xen/grant-table.c
> @@ -664,7 +664,6 @@ static int grow_gnttab_list(unsigned int more_frames)
>   	unsigned int nr_glist_frames, new_nr_glist_frames;
>   	unsigned int grefs_per_frame;
>   
> -	BUG_ON(gnttab_interface == NULL);
>   	grefs_per_frame = gnttab_interface->grefs_per_grant_frame;
>   
>   	new_nr_grant_frames = nr_grant_frames + more_frames;
> @@ -1388,7 +1387,9 @@ static int gnttab_expand(unsigned int req_entries)
>   	int rc;
>   	unsigned int cur, extra;
>   
> -	BUG_ON(gnttab_interface == NULL);
> +	if (!gnttab_interface)
> +		return -EINVAL;
> +
>   	cur = nr_grant_frames;
>   	extra = ((req_entries + gnttab_interface->grefs_per_grant_frame - 1) /
>   		 gnttab_interface->grefs_per_grant_frame);
> @@ -1423,7 +1424,9 @@ int gnttab_init(void)
>   	/* Determine the maximum number of frames required for the
>   	 * grant reference free list on the current hypervisor.
>   	 */
> -	BUG_ON(gnttab_interface == NULL);
> +	if (!gnttab_interface)
> +		return -EINVAL;
> +

I'd just remove the BUG_ON().

gnttab_request_version() called some lines up always sets
gnttab_interface.

The BUG_ON() in nr_status_frames() can be removed, too. It is either
called by v2 specific functions (for those to be reached
gnttab_interface must be set) or by gnttab_init() (reasoning see
above).


Juergen

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-12-16  7:38 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-15 20:13 [PATCH] xen/grant-table: remove unnecessary BUG_ON on gnttab_interface Aditya Pakki
2019-12-15 20:13 ` [Xen-devel] " Aditya Pakki
2019-12-16  7:38 ` Jürgen Groß
2019-12-16  7:38   ` [Xen-devel] " Jürgen Groß

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.