Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752012AbdCIGrc (ORCPT ); Thu, 9 Mar 2017 01:47:32 -0500 Received: from hqemgate15.nvidia.com ([216.228.121.64]:1559 "EHLO hqemgate15.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751168AbdCIGrb (ORCPT ); Thu, 9 Mar 2017 01:47:31 -0500 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Wed, 08 Mar 2017 22:46:47 -0800 Subject: Re: [RFC 08/11] mm: make ttu's return boolean To: Minchan Kim References: <1488436765-32350-1-git-send-email-minchan@kernel.org> <1488436765-32350-9-git-send-email-minchan@kernel.org> <70f60783-e098-c1a9-11b4-544530bcd809@nvidia.com> <20170309063721.GC854@bbox> CC: Andrew Morton , , , , Johannes Weiner , Michal Hocko , "Kirill A. Shutemov" , Naoya Horiguchi X-Nvconfidentiality: public From: John Hubbard Message-ID: <49da6c96-387f-5931-eddb-cb6414631877@nvidia.com> Date: Wed, 8 Mar 2017 22:46:40 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.1 MIME-Version: 1.0 In-Reply-To: <20170309063721.GC854@bbox> X-Originating-IP: [10.2.166.22] X-ClientProxiedBy: DRHQMAIL102.nvidia.com (10.27.9.11) To HQMAIL107.nvidia.com (172.20.187.13) Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2035 Lines: 74 On 03/08/2017 10:37 PM, Minchan Kim wrote: >[...] > > I think it's the matter of taste. > > if (try_to_unmap(xxx)) > something > else > something > > It's perfectly understandable to me. IOW, if try_to_unmap returns true, > it means it did unmap successfully. Otherwise, failed. > > IMHO, SWAP_SUCCESS or TTU_RESULT_* seems to be an over-engineering. > If the user want it, user can do it by introducing right variable name > in his context. See below. I'm OK with that approach. Just something to avoid the "what does !ret mean in this function call" is what I was looking for... >> [...] >>> forcekill = PageDirty(hpage) || (flags & MF_MUST_KILL); >>> - kill_procs(&tokill, forcekill, trapno, >>> - ret != SWAP_SUCCESS, p, pfn, flags); >>> + kill_procs(&tokill, forcekill, trapno, !ret , p, pfn, flags); >> >> The kill_procs() invocation was a little more readable before. > > Indeed but I think it's not a problem of try_to_unmap but ret variable name > isn't good any more. How about this? > > bool unmap_success; > > unmap_success = try_to_unmap(hpage, ttu); > > .. > > kill_procs(&tokill, forcekill, trapno, !unmap_success , p, pfn, flags); > > .. > > return unmap_success; > > My point is user can introduce whatever variable name depends on his > context. No need to make return variable complicated, IMHO. Yes, the local variable basically achieves what I was hoping for, so sure, works for me. >> [...] >>> - case SWAP_FAIL: >> >> Again: the SWAP_FAIL makes it crystal clear which case we're in. > > To me, I don't feel it. > To me, below is perfectly understandable. > > if (try_to_unmap()) > do something > > That's why I think it's matter of taste. Okay, I admit I might be > biased, too so I will consider what you suggested if others votes > it. Yes, if it's really just a matter of taste, then not worth debating. Your change above is fine I think. thanks john h > > Thanks. >