Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp6430069rdb; Tue, 2 Jan 2024 01:12:30 -0800 (PST) X-Google-Smtp-Source: AGHT+IFue0uXeWy1zDYlMcLcspZSY2nukSp1cKTcpAFqMX/BhAkNholQdyDlr0+Xb9yjVTjOCgqH X-Received: by 2002:a17:902:b94c:b0:1d0:6ffe:a11 with SMTP id h12-20020a170902b94c00b001d06ffe0a11mr19903620pls.111.1704186749856; Tue, 02 Jan 2024 01:12:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704186749; cv=none; d=google.com; s=arc-20160816; b=aFqFRNJaoOBz+GCZq8kzq+V8spxDx/RfJ+l724nCH+4w0IU0GAIepaLXPgXXGCtGvT bJN1xgm4cboeBNRAnzeRMy4UPAlz0eJGWe0e1sM4c5s6rJeLbRGVDfVVcOV3ln0R4V49 KtcK7eg8z0ppLiNdo/TDgZBtdxo30R2CNOO58JYmR2ttxhV6F/nwQAmgz3nCtlYsRz7V 8gmfy7m69PZmf6OAKwpg5x83tcuvPKWSaV2Iuob7YTV0GNp6ivRnxsz9ZPRyg0fJ9/gL UiQEJCbcT+TJ2YC3j+w63hrfOaqTYUW1NwoWC/z0s1eKEECByEItOVG0itLpwDHN93kU 1EYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :user-agent:message-id:date:references:in-reply-to:subject:cc:to :from:dkim-signature; bh=dDzw5Fr+n5e6mYrOCxXvmkE5KV/HrNnFHAXrJwNWsrY=; fh=c7ePy/H+EU8l/QScff/FSGM28oG5aGlbY41VeFjD3tI=; b=KiFG6NRgCn41JnXvXfzxwaeHQAnXBSbNYxDAyHUCwCDtZe7IZNhR9XtyOSAkLRlZVK DT9fKUUGLifvqK3VvdHTQH3ZjQD31/A7IfoafcrOwsar4hUZ1qJTZefh+gPZOTKmkRqa dFIpbAzKiDKKNJo8Cu4/32egUGzdpACPObcEsLrXZ8uY3radadfJS/PEvD0UqpnC9Ivs ihWOKCmLthHIqW4hIC83VrdHfDfj+q1vIWAfiMTPJNJMI9kwt47wDowFMmeUnvgaQpkX 0LLv+qP7p+STkfVfui4ww0sb8cP178uP30UvBTe59T4xue4SX5PVRtoN7+yGbRh4wcsx fqAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Dgpv6VQH; spf=pass (google.com: domain of linux-kernel+bounces-14171-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-14171-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id kg5-20020a170903060500b001d00a92b9d4si19438982plb.575.2024.01.02.01.12.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jan 2024 01:12:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-14171-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Dgpv6VQH; spf=pass (google.com: domain of linux-kernel+bounces-14171-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-14171-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 30513282CD8 for ; Tue, 2 Jan 2024 09:12:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DEBE4CA6B; Tue, 2 Jan 2024 09:12:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Dgpv6VQH" X-Original-To: linux-kernel@vger.kernel.org Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.88]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0DAE15697; Tue, 2 Jan 2024 09:12:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1704186724; x=1735722724; h=from:to:cc:subject:in-reply-to:references:date: message-id:mime-version; bh=ZUUp125/reT7Tq22vhlJmnu5Uponk8HjKBT4ndhBEac=; b=Dgpv6VQHu3RhxV2FCj+bDXw6/JYN7kFKFDMw0VLe/GyMXKXFjx37NFx7 K9LSIovE6Kw0NbY45E3ewL/LVCkqSyc9vFtY1zRkrucuSevmp03Kc/Gx1 BUskTf+QwAQ6jFEv6rLxIqVPtsHfb2FCSpEFmeVw4FpbaU9QBSO6fu8o7 vJ4faPt4aPjLfcwkRYZQsHcs3dRTVN24NQnIjwBRKkLqXJwsDq+k6jmwp KeqHyEX9IxdYradK1IKV6CkTcDimj7gFxy9LrhNxQRe77zX/U0mjJI8rc ovixFAUDkMUn7cSwNt1lPuELuYUJAYBckThS03ByJ5n3gR3GoGmotY0ON g==; X-IronPort-AV: E=McAfee;i="6600,9927,10940"; a="428020231" X-IronPort-AV: E=Sophos;i="6.04,324,1695711600"; d="scan'208";a="428020231" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jan 2024 01:12:01 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10940"; a="755861313" X-IronPort-AV: E=Sophos;i="6.04,324,1695711600"; d="scan'208";a="755861313" Received: from yhuang6-desk2.sh.intel.com (HELO yhuang6-desk2.ccr.corp.intel.com) ([10.238.208.55]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jan 2024 01:11:53 -0800 From: "Huang, Ying" To: Gregory Price Cc: Gregory Price , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: Re: [PATCH v5 03/11] mm/mempolicy: refactor sanitize_mpol_flags for reuse In-Reply-To: (Gregory Price's message of "Tue, 26 Dec 2023 06:48:34 -0500") References: <20231223181101.1954-1-gregory.price@memverge.com> <20231223181101.1954-4-gregory.price@memverge.com> <87y1dgdoou.fsf@yhuang6-desk2.ccr.corp.intel.com> Date: Tue, 02 Jan 2024 17:09:55 +0800 Message-ID: <871qb0drto.fsf@yhuang6-desk2.ccr.corp.intel.com> User-Agent: Gnus/5.13 (Gnus v5.13) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=ascii Gregory Price writes: > On Tue, Dec 26, 2023 at 02:05:35AM -0500, Gregory Price wrote: >> On Wed, Dec 27, 2023 at 04:39:29PM +0800, Huang, Ying wrote: >> > Gregory Price writes: >> > >> > > + unsigned short mode = (*mode_arg & ~MPOL_MODE_FLAGS); >> > > + >> > > + *flags = *mode_arg & MPOL_MODE_FLAGS; >> > > + *mode_arg = mode; >> > >> > It appears that it's unnecessary to introduce a local variable to split >> > mode/flags. Just reuse the original code? >> > > > Revisiting during fixes: Note the change from int to short. > > I chose to make this explicit because validate_mpol_flags takes a short. > > I'm fairly sure changing it back throws a truncation warning. Why something like below doesn't work? int sanitize_mpol_flags(int *mode, unsigned short *flags) { *flags = *mode & MPOL_MODE_FLAGS; *mode &= ~MPOL_MODE_FLAGS; return validate_mpol_flags(*mode, flags); } -- Best Regards, Huang, Ying