Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2761325rwb; Fri, 2 Dec 2022 14:49:38 -0800 (PST) X-Google-Smtp-Source: AA0mqf7Wp1NbA0X/WpzvkuCZBnvxYI0EnGOXbnBZHiyiiXVelogjoCpZK9MvwVpo1OTAyUK+RBt7 X-Received: by 2002:a63:4b07:0:b0:46e:9363:d96e with SMTP id y7-20020a634b07000000b0046e9363d96emr47135664pga.85.1670021378166; Fri, 02 Dec 2022 14:49:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670021378; cv=none; d=google.com; s=arc-20160816; b=LSdZ0ebauCY4frjM3CvWQvoNzWnxVBSwTKhYgdY2HQEyvM8taj38TarIcOwJV5F8B5 Tx+H9nAG9hUfQUUWxzwKwsyuNSR8RfZ0Px5p18TPcdByY9n20FE29+mW2aKiuGeOj5lQ zcuSUhNKYZO/L2rtP3uVggLuexUnW3rFDbQkR4YA/JVURgGFfYnTyTlo6EQY+BhMnl0i XfyO9jEzHylefNLT9yV9dTkr7hREyDVV01TQpxvBehaf/RtMZ+DxRoOQsC6zVF+AfT7e sZB5fufIiG/RaAj9cgR1cuHX+gc9Lle5f0JiOLiidWMooTQNxgOEEwFB58lYlVPdZ4dp WzKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=5sIYAxwZltAVbHjS/wBuhIMHrc/V/GUzZquiLHxn1/g=; b=XsX1KaSJeITCImMhS1ma3dnRRZx9w14OQzzJwVjKJsn/rPcc4gTww/ZUKrIzWkc7V5 BbMIcu+n+h+wkys+fLcSISH/SYfFK7PVXCcXguXA4Wg8uk+SS4+UC1B2DEFXUH64zbqT AICfCAZge+Y+6mUU+w1BwnIZNrgme8y1D57FoQAbTiYXB+vb4L2p+Ljuv5S4wbxfOpQB dbfbLOBzmSRenzrKuhnG584T/+eoBglFyAuzdxWG2Thm4wiLtSg0OalZhSHyA54A/Evl /P1PiL+nooa7VCmwAUP6zRa25kRVfiCLgWjmy0+ilTQVQjjsH/CNaalAfUN5vJDgaHUH Moww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=DCaujLzm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e27-20020a630f1b000000b00477b10def88si8341517pgl.696.2022.12.02.14.49.27; Fri, 02 Dec 2022 14:49:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=DCaujLzm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234668AbiLBWhN (ORCPT + 82 others); Fri, 2 Dec 2022 17:37:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60714 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234389AbiLBWhM (ORCPT ); Fri, 2 Dec 2022 17:37:12 -0500 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CCF20B0DFC; Fri, 2 Dec 2022 14:37:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1670020631; x=1701556631; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=fDwnio0U3LHuhov+sUpgA5OaZfMyZJrWLLg1iX6CVrY=; b=DCaujLzmEmaes1iDYCqZKoknKhAaNQHNF7DsUv8LTAdbvBfmdJ1KJFXU 5pKwxoiGeHwWTECxG6RDh4PF9VlWL8MKriJpE2BdmSeExmQHekPrvlC06 YyPxxVGMs/FK6XT4op1I8zjmfYCdYj+mmP4RM48K0z4wC2XQLhihR63/w M9VeQEWQqH5Z4ZoNKWunxZp5EOevANx7QaSdyqJ+BVgLY0ERlyoZXavBd vFF7F6P7iNUUx8w9A6Zs0w5ZiShiMyo0/ZJSHQQXXc7nW9LohEHUbmB5q Iva1VY+KHM9TmrCWUiN4m2ijvLZYYSROFVMzlYczcJIU46fljm9VDZIx6 g==; X-IronPort-AV: E=McAfee;i="6500,9779,10549"; a="402339708" X-IronPort-AV: E=Sophos;i="5.96,213,1665471600"; d="scan'208";a="402339708" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Dec 2022 14:37:11 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10549"; a="713785122" X-IronPort-AV: E=Sophos;i="5.96,213,1665471600"; d="scan'208";a="713785122" Received: from rsnyder-mobl.amr.corp.intel.com (HELO [10.209.68.71]) ([10.209.68.71]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Dec 2022 14:37:10 -0800 Message-ID: <47799f29-8856-8c87-240b-0667f74a3be8@intel.com> Date: Fri, 2 Dec 2022 14:37:09 -0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.2 Subject: Re: [PATCH v2 01/18] x86/sgx: Call cond_resched() at the end of sgx_reclaim_pages() Content-Language: en-US To: Kristen Carlson Accardi , jarkko@kernel.org, dave.hansen@linux.intel.com, tj@kernel.org, linux-kernel@vger.kernel.org, linux-sgx@vger.kernel.org, cgroups@vger.kernel.org, Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org, "H. Peter Anvin" Cc: zhiquan1.li@intel.com, Sean Christopherson References: <20221202183655.3767674-1-kristen@linux.intel.com> <20221202183655.3767674-2-kristen@linux.intel.com> <37de083d-a63b-b2ff-d00a-e890a1ba5eea@intel.com> <746adf31-e70c-e32d-a35d-72d352af613b@intel.com> <307b43aa5908c489913110287044e611f574db0a.camel@linux.intel.com> From: Dave Hansen In-Reply-To: <307b43aa5908c489913110287044e611f574db0a.camel@linux.intel.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12/2/22 14:17, Kristen Carlson Accardi wrote: > On Fri, 2022-12-02 at 13:45 -0800, Dave Hansen wrote: >> On 12/2/22 13:37, Kristen Carlson Accardi wrote: >>>>> +static void sgx_reclaim_pages(void) >>>>> +{ >>>>> +       __sgx_reclaim_pages(); >>>>> +       cond_resched(); >>>>> +} >>>> Why bother with the wrapper?  Can't we just put cond_resched() in >>>> the >>>> existing sgx_reclaim_pages()? >>> Because sgx_reclaim_direct() needs to call sgx_reclaim_pages() >>> but not do the cond_resched(). It was this or add a boolean or >>> something to let caller's opt out of the resched. >> >> Is there a reason sgx_reclaim_direct() *can't* or shouldn't call >> cond_resched()? > > Yes, it is due to performance concerns. It is explained most succinctly > by Reinette here: > > https://lore.kernel.org/linux-sgx/a4eb5ab0-bf83-17a4-8bc0-a90aaf438a8e@intel.com/ I think I'd much rather have 3 cond_resched()s in the code that effectively self-document than one __something() in there that's a bit of a mystery. Everyone knows what cond_resched() means.