Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp1171307ybj; Thu, 7 May 2020 16:51:55 -0700 (PDT) X-Google-Smtp-Source: APiQypIS2O9IeVvdtXZpJ/CHrSK6NrDcah1ltQbZB+uU1FzyCq7QhMchYdRLu34Zh/ImS3j1kRF5 X-Received: by 2002:a05:6402:17ef:: with SMTP id t15mr14277883edy.10.1588895515474; Thu, 07 May 2020 16:51:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588895515; cv=none; d=google.com; s=arc-20160816; b=cXdyOMiBAuTRjTk8c3wDEl5itKGTGVcZpaM4NA0ftRlcks1fzEp18RaKIvEivhZZeP eJZ9QZozIxHysUW0Y/J6LyUsKMbCEVsIcfoUHIuL7c3eWro81sDKIPt3Oh9YFz3tTps8 P1xsxyW+NRPG7wqK7caHZevuHpS8j7NHKzrfxaABMErnUOITmmZWN0HTE+CilcIZzZMK 0hGtkpTKKBvRr50XTzAovtR0ZWAsgvNJizlteL6NjiWQpU1hX5oPmJDzTOAaOV1X4tEd 1yFd7bBSiWTEkw/6JPFxn5BU1gW3U3T0ucD41mKO4jJWx1wW4nB2w/C0KMr2dsuitGI+ 0lPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:message-id :in-reply-to:date:references:subject:cc:to:from:ironport-sdr :ironport-sdr; bh=5eKWRshQQcj4A3QtovS+TlU0FM5MC8wtuRHuwcPjx0k=; b=tFjHGEc741vxooJ1wmdIBfYy/4RRMWEW9JPzvvQZEjfwH3lDD9NE370HNF29zL+mLc DQq01n3094qpqdpJFbOaK60cgdPs/RhLUOcFPh8N3ed9WYQhAPFkVmP2SEsvUQlFgpM8 4ogmPq1LfKZ6TsIQ7cebDorV+SZS3t8ogeW/spUYLJVEb8xi2KyUNb9fd/8ic/5bogbk pc3/hNFe1W+d4FDaz7zXjHz4AmJS6YSQCCsUOuRp0m5fjSPcnnrhkLe27cFiJrZvzZAA FEDiYEaipjcsThi2ySdaeECoC+CC2p6tIQ43SYTQDvJEY8yz46MwROEHErH/vi2kAyhR M1Yg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y24si3988891edo.538.2020.05.07.16.51.31; Thu, 07 May 2020 16:51:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726542AbgEGXsD (ORCPT + 99 others); Thu, 7 May 2020 19:48:03 -0400 Received: from mga17.intel.com ([192.55.52.151]:62619 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726476AbgEGXsD (ORCPT ); Thu, 7 May 2020 19:48:03 -0400 IronPort-SDR: J6U5wv0sg+BZ/bVCkwWE6Qlj7gI88Qlc4rQ93W3eOH4rhz+DJh5P2y7uA4lal4sa8rkUxOyo2q tjfawGK+nK0A== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 May 2020 16:48:03 -0700 IronPort-SDR: GKEG8s1+doVujsqoPhz2CY1V7gn0+U9w/t5Etzm5A8ieEph4hwY2VxVwb5slULMh2QyOY8lUS8 tEfvD5dAkvHw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,365,1583222400"; d="scan'208";a="462037332" Received: from yhuang-dev.sh.intel.com (HELO yhuang-dev) ([10.239.159.23]) by fmsmga005.fm.intel.com with ESMTP; 07 May 2020 16:48:01 -0700 From: "Huang\, Ying" To: Wei Yang Cc: Andrew Morton , , , willy@infradead.org Subject: Re: [PATCH 3/3] mm/swapfile.c: count won't be bigger than SWAP_MAP_MAX References: <20200501015259.32237-1-richard.weiyang@gmail.com> <20200501015259.32237-3-richard.weiyang@gmail.com> <20200501154853.bca4cfb7b2558bd43a4942f3@linux-foundation.org> <20200502132911.u6y6hkh56ik4ojne@master> <87k11pv5ep.fsf@yhuang-dev.intel.com> <20200507222014.6s5szrt6zy2b6ybo@master> Date: Fri, 08 May 2020 07:48:01 +0800 In-Reply-To: <20200507222014.6s5szrt6zy2b6ybo@master> (Wei Yang's message of "Thu, 7 May 2020 22:20:14 +0000") Message-ID: <87ftcbtiha.fsf@yhuang-dev.intel.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=ascii Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Wei Yang writes: > On Wed, May 06, 2020 at 04:22:54PM +0800, Huang, Ying wrote: >>Wei Yang writes: >> >>> On Fri, May 01, 2020 at 03:48:53PM -0700, Andrew Morton wrote: >>>>On Fri, 1 May 2020 01:52:59 +0000 Wei Yang wrote: >>>> >>>>> When the condition is true, there are two possibilities: >>>> >>>>I'm struggling with this one. >>>> >>>>> 1. count == SWAP_MAP_BAD >>>>> 2. count == (SWAP_MAP_MAX & COUNT_CONTINUED) == SWAP_MAP_SHMEM >>>> >>>>I'm not sure what 2. is trying to say. For a start, (SWAP_MAP_MAX & >>>>COUNT_CONTINUED) is zero. I guess it meant "|"? >>> >>> Oops, you are right. It should be (SWAP_MAP_MAX | COUNT_CONTINUED). >>> >>> Sorry for the confusion. >>> >>>> >>>>Also, the return value documentation says we return EINVAL for migration >>>>entries. Where's that happening, or is the comment out of date? >>>> >>> >>> Not paid attention to this. >>> >>> Take look into the code, I don't find a relationship between the swap count >>> and migration. Seems we just make a migration entry but not duplicate it. >>> If my understanding is correct. >> >>Per my understanding, one functionality of the error path is to catch >>the behavior that shouldn't happen at all. For example, if >>__swap_duplicate() is called for the migration entry because of some >>race condition. >> > > If __swap_duplicate() run for a migration entry, it returns since > get_swap_entry() couldn't find a swap_info_struct. So the return value is > -EINVAL. > > While when this situation would happen? And the race condition you mean is? Sorry for confusing. I don't mean there are some known race conditions in current kernel that will trigger the error code path. I mean we may use the error path to identify some race conditions in the future. I remember that Matthew thought that the swap code should work reasonably even for garbage PTE. Best Regards, Huang, Ying >>Best Regards, >>Huang, Ying